-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContactForm.js
70 lines (49 loc) · 1.54 KB
/
ContactForm.js
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
var state= new Array();
var country=new Array();
state[0]="";
state[1]="Rajasthan";
state[2]="Maharashtra";
state[3]="Karnataka";
state[4]="Maharashtra";
country[0]="";
country[1]="India";
country[2]="India";
country[3]="India";
country[4]="India";
function userStateAndCountry(){
x=document.getElementById("userCityOptions");
document.getElementById("userState").value=state[x.selectedIndex];
document.getElementById("userCountry").value=country[x.selectedIndex];
}
function validateForm(){
for(var i=4; i<=6;i++){
boxElement=document.ContactForm.elements[i];
if(!boxElement.value){
alert('You have not filled the ' +boxElement.name+ '!');
boxElement.focus();
return false;
}
}
characterInput=document.getElementById("userFullName");
var characterInputFormat=/^([a-zA-Z]+\s)*[a-zA-Z]+$/;
if(!characterInput.value.match(characterInputFormat)){
alert('Please fill characters only');
characterInput.focus();
return false;
}
emailId= document.getElementById("userEmailId");
var emailFormat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if (!emailId.value.match(emailFormat)) {
alert("Not a valid e-mail address");
emailId.focus();
return false;
}
phoneNumber= document.getElementById("userPhoneNo");
var phoneNumberFormat = /^[0-9]+$/;
if (!phoneNumber.value.match(phoneNumberFormat)) {
alert("Please enter numbers only");
emailId.focus();
return false;
}
return true;
}