-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjjs9.js
30 lines (19 loc) · 1.91 KB
/
jjs9.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
function validateForm() {
var validate_flag = true;
var pat_email = /^[a-zA-Z]([a-zA-Z0-9+.\-][.]?)*@[a-zA-Z0-9]+.[a-zA-Z]{2,4}.[a-zA-Z]{0,3}$/;
var pat_url = /^([a-zA-Z][a-zA-Z0-9]*:)(\/\/([a-zA-Z0-9]+:[a-zA-Z0-9]+@)?((www.)?([a-zA-Z0-9][a-zA-Z0-9\-]{1,61}[a-zA-Z0-9])(.[a-zA-Z0-9][a-zA-Z0-9\-]{1,61}[a-zA-Z0-9])*.[a-zA-Z]{2,4}.[a-zA-Z]{0,3})(:[0-9]{1,5})?)(\/[a-zA-Z0-9_.+\-]+)*(\?([a-zA-Z0-9][a-zA-Z0-9_.+\-]*=[a-zA-Z0-9+\-._,]+[;&]?)*)?(#[a-zA-z][a-zA-Z0-9._+\-,]*)*$/;
if (document.getElementById("login").value.length === 0) { alert("Login Id can't be left Blank"); validate_flag = false; }
if (document.getElementById("email").value.length === 0) { alert("Email Address can't be left Blank"); validate_flag = false; } else {
if(pat_email.test(document.getElementById("email").value)) { alert("Yes, " + document.getElementById("email").value + " is a valid E-mail Address"); }
else { alert("no, " + document.getElementById("email").value + " is not a valid E-mail Address"); validate_flag = false; }
}
if (document.getElementById("name").value.length === 0) { alert("Name can't be left Blank"); validate_flag = false; }
if (document.getElementById("home").value.length === 0) { alert("Home Page can't be left Blank"); validate_flag = false; }
else {
if(pat_url.test(document.getElementById("home").value)) { alert("Yes, " + document.getElementById("home").value + " is a valid URL"); }
else { alert("No, " + document.getElementById("home").value + " is not a valid URL"); validate_flag = false; }
}
if (document.getElementById("aboutme").value.length < 50) { alert("About Me should have a min. word limit of 50 characters."); validate_flag = false; }
if (document.getElementById("receive").checked === false) { alert("Please select Receive Notification Checkbox"); validate_flag = false; }
if (validate_flag === false) { return false; }
}