-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegistrationForm.js
More file actions
146 lines (128 loc) · 3.89 KB
/
RegistrationForm.js
File metadata and controls
146 lines (128 loc) · 3.89 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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
function formValidation() {
uid = document.RegistrationForm.userid;
passid = document.RegistrationForm.passid;
uname = document.RegistrationForm.username;
userAddress = document.RegistrationForm.address;
userCountry =document.RegistrationForm.country;
uzip = document.RegistrationForm.zip;
userEmail = document.RegistrationForm.email;
umsex = document.RegistrationForm.msex;
ufsex = document.RegistrationForm.fsex;
if(userid_validation(uid,5,12)){
if(passid_validation(passid,7,12)){
if(allLetter(uname)){
if(alphanumeric(userAddress)){
if (contryselect(userCountry)){
if (allnumeric(uzip)){
if (ValidateEmail(userEmail)){
if (validsex(umsex,ufsex)){
}
}
}
}
}
}
}
}
return false;
}
//----------------------------------------------------------1
function userid_validation(uid, mx, my) {
UserIdLength = uid.value.length;
if (UserIdLength == 0 || UserIdLength >=my || UserIdLength<mx){
alert("User Id should no be empty / length be between" + mx +" to "+my);
uid.focus();
return false;
}
return true;
}
//----------------------------------------------------------2
function passid_validationf(passid,mx,my) {
PassLength = passid.value.length;
if (PassLength== 0 || PassLength >=my || PassLength <mx){
alert("User password should no be empty / length be between" + mx +" to "+my);
passid.focus();
return false;
}
return true;
}
//----------------------------------------------------------------------3
function allLetter(uname) {
//letters = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
letters = /^[A-Za-z]+$/;
if (uname.value.match(letters)) {
//alert("ur email is valid ");
return true;
} else {
alert("You must have alphabet characters only");
uname.focus();
return false;
}
}
//-------------------------------------------------------------------------4
function alphanumeric(userAddress) {
//letters = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
letters = /^[0-9A-Za-z]+$/;
if (userAddress.value.match(letters)) {
//alert("ur email is valid ");
return true;
} else {
alert("You must have alphabet alpha numeric characters only");
userAddress.focus();
return false;
}
}
//--------------------------------------------------------------5
function contryselect(userCountry){
if (userCountry.value == "Default"){
alert("Select your country from the list.");
userCountry.focus();
return false;
}
else {
return true;
}
}
//---------------------------------------------------------------------6
function allnumeric(uzip) {
letters = /^[0-9]+$/;
if (uzip.value.match(letters)) {
//alert("ur email is valid ");
return true;
} else {
alert("Zip code must be numeric characters only");
uzip.focus();
return false;
}
}
//------------------------------------------------------------------------7
function ValidateEmail(userEmail){
letters = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if (userEmail.value.match(letters)) {
//alert("ur email is valid ");
return true;
} else {
alert("You must have input valid email.");
userEmail.focus();
return false;
}
}
//--------------------------------------------------------8
function validsex(umsex,ufsex){
x = 0;
if(umsex.checked()){
x++;
}
if(ufsex.checked()){
x++;
}
if(x==0){
alert("Select Male/Female");
return false;
}
else {
alert('Form Successfully Submitted');
window.location.reload();
return true;
}
}