-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodility-TrendTechnology-02.js
More file actions
43 lines (39 loc) · 1.09 KB
/
Codility-TrendTechnology-02.js
File metadata and controls
43 lines (39 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//Form Validation
function TrendSolution2() {
var person = $("#type_person").is(":checked");
var company = $("#type_company").is(":checked");
var firstname = $("#first_name").val();
var lastname = $("#last_name").val();
var email = $("#email").val();
var companyname = $("#company_name").val();
var phone = $("#phone").val();
var result = true
if (person) {
if (firstname.match(/[a-zA-Z/]+/)== null){
result = false;
}
if (lastname.match(/[a-zA-Z/]+/)== null){
result = false;
}
if (email.match(/^[a-zAZ.]{1,64}@[a-zA-Z.]{1,64}$/)== null) {
result = false;
}
} else if (company) {
if (companyname.match(/[/a-zA-Z]+/) == null) {
result = false;
}
if (phone.match(/^[\d]{3}-^[\d]{3}-^[\d]{3}/) == null) {
result = false;
}
} else {
return false;
}
return result;
}
// console.log(person)
// console.log( company )
// console.log(firstname)
// console.log(lastname )
// console.log(email)
// console.log(companyname)
// console.log(phone )