-
Notifications
You must be signed in to change notification settings - Fork 1
/
form.js
83 lines (73 loc) · 2.2 KB
/
form.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
71
72
73
74
75
76
77
78
79
80
81
82
83
function checkfun(form2)
{
allLetter(form2.name);
strleng(form2.name);
ValidateEmail(form2.email);
var x = checkPassword(form2);
}
function calling()
{
if (window.confirm("Would you like to go to Yahoo !!")) {
window.location.href="http://www.yahoo.com";
}
}
//name alphabet check-------------------------------------------------
function allLetter(inputtxt)
{
var letters = /^[A-Za-z]+$/;
if(inputtxt.value.match(letters))
{
return true;
}
else
{
alert('Please input alphabet characters only without spaces for USERNAME!');
return false;
}
}
//----name length check-------------------------------------------------------------------------------
function strleng(inputtxt)
{
var field = inputtxt.value;
var mnlen = 5;
if(field.length<mnlen)
{
alert("Username must be atleast 5 characters long!");
return false;
}
else
{
return true;
}
}
//---email check-----------------------------------------------------------------------------------------
function ValidateEmail(inputText)
{
var mailformat = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
if(inputText.value.match(mailformat))
{
document.form1.email.focus();
return true;
}
else
{
alert("You have entered an invalid email address!");
document.form1.email.focus();
return false;
}
}
//----------password check----------------------------------------------------------//
function checkPassword() {
var password = document.getElementById("password1").value;
var confirmPassword = document.getElementById("password2").value;
if (password != confirmPassword || (password=='' && confirmPassword=="") ) {
alert("Passwords do not match!Please try again...");
return false;
}
else
{
alert('Thank You! Information Submitted Successfully.Press ok to view official page.')
window.open('catalyticoriginals-master/index.html');
}
return true;
}