-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontact.js
More file actions
51 lines (46 loc) · 1.76 KB
/
contact.js
File metadata and controls
51 lines (46 loc) · 1.76 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
44
45
46
47
48
49
50
51
function ValidateEmail(input) {
if(document.getElementById(input).value == ""){
document.getElementById("EmailError").innerHTML="Please enter Email address";
return false;
}
var validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
if ( !document.getElementById(input).value.match(validRegex)) {
document.getElementById("EmailError").innerHTML="Invalid email address!";
return false;
}
return true;
}
function onFormSubmit(){
//document.getElementsByClassName("validation-error").innerHTML="";
validateIfEmpty("fullName");
ValidateEmail("Email");
validateIfEmpty("Address");
validateIfEmpty("City");
validatePostalCode("PostalCode");
}
function validateIfEmpty(input){
if(document.getElementById(input).value == ""){
document.getElementById(input+"Error").innerHTML="Please enter "+input;
}
}
function validatePostalCode(input){
if(document.getElementById(input).value == ""){
document.getElementById("PostalCodeError").innerHTML="Please enter Postal Code";
return false;
}
var validRegex = /^[A-Za-z]\d[A-Za-z][ -]?\d[A-Za-z]\d$/;
if ( !document.getElementById(input).value.match(validRegex)) {
document.getElementById("PostalCodeError").innerHTML="Invalid postal code!";
return false;
}
document.getElementById("frmContact").submit();
return true;
}
function popTextarea(){
document.getElementById("txtHiring").style.display="none";
document.getElementById("txtarea").style.display="block";
}
function popTextbox(){
document.getElementById("txtarea").style.display="none";
document.getElementById("txtHiring").style.display="block";
}