-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.js
207 lines (186 loc) · 6.21 KB
/
signup.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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// JavaScript Document
var flag;
function formVal(){
flag= true;
var username=document.getElementById('username').value;
var password=document.getElementById('password').value;
var cpassword=document.getElementById('cpassword').value;
var email=document.getElementById('email').value;
var sex0=document.form1.sex[0].checked; // returm true or false
var sex1=document.form1.sex[1].checked;
var day=document.getElementById('day').value;
var month=document.getElementById('month').value;
var year=document.getElementById('year').value;
if(username=="" || !isNaN(username)){
//no numbers at start
flag=false;
document.getElementById('usernameo2').innerHTML="fill please no numbers included";
document.getElementById('usernameo1').innerHTML="*";
}else{
document.getElementById('usernameo2').innerHTML="";
document.getElementById('usernameo1').innerHTML="";
}
/*-------------------------------------------------------
var regular = /^[a-zA-Z]/;
if(regular.test(password) && password.length>=10){
document.getElementById('password2').innerHTML="";
document.getElementById('password1').innerHTML="";
}
else{
document.getElementById('password2').innerHTML="must include letter and your password must be at least 10 characters";
document.getElementById('password1').innerHTML="*";
flag=false;
}
var regular = /[0-9]/;
if(regular.test(password) && password.length>=10){
document.getElementById('password2').innerHTML="";
document.getElementById('password1').innerHTML="";
}
else{
document.getElementById('password2').innerHTML="must include number and your password must be at least 10 characters";
document.getElementById('password1').innerHTML="*";
flag=false;
}
*/
//--------------------------------------------
var regular1 = /^[a-zA-Z]/;
var regular2 = /[0-9]/;
if(regular1.test(password) )
{
if(regular2.test(password))
{
if(password.length>=10)
{
document.getElementById('password2').innerHTML="";
document.getElementById('password1').innerHTML="";
document.getElementById('color').style.backgroundColor="lime";
}
else{
document.getElementById('color').style.backgroundColor="yellow";
document.getElementById('password2').innerHTML="at least 10 letters and numbers";
document.getElementById('password1').innerHTML="*";
flag=false;
}
}
else{
if(password.length>=10)
{
document.getElementById('color').style.backgroundColor="yellow";
document.getElementById('password2').innerHTML="at least 1 number";
document.getElementById('password1').innerHTML="*";
flag=false;
}
else
{
document.getElementById('color').style.backgroundColor="red";
document.getElementById('password2').innerHTML="at least 10 letters and numbers";
document.getElementById('password1').innerHTML="*";
flag=false;
}
}
}
else{
if(regular1.test(password))
{
if(password.length>=10)
{
document.getElementById('password2').innerHTML="";
document.getElementById('password1').innerHTML="";
document.getElementById('color').style.backgroundColor="lime";
}
else{
document.getElementById('color').style.backgroundColor="yellow";
document.getElementById('password2').innerHTML="at least 10 letters and numbers";
document.getElementById('password1').innerHTML="*";
flag=false;
}
}
else{
if(password.length>=10)
{
document.getElementById('color').style.backgroundColor="yellow";
document.getElementById('password2').innerHTML="at least 1 letter";
document.getElementById('password1').innerHTML="*";
flag=false;
}
else
{
document.getElementById('color').style.backgroundColor="red";
document.getElementById('password2').innerHTML="at least 10 letters and numbers";
document.getElementById('password1').innerHTML="*";
flag=false;
}
}
}
//------------------------------------------------
if(cpassword!=password){
flag=false;
document.getElementById('cpassword2').innerHTML="not matching";
document.getElementById('cpassword1').innerHTML="*";
}
else{
document.getElementById('cpassword2').innerHTML="";
document.getElementById('cpassword1').innerHTML="";
}
//-------------------------------------------------
var reg =/^([a-zA-Z0-9_.-]) @([a-zA-Z0-9_.-]) \.([a-zA-Z]) ([a-zA-Z]) /;
if (reg.test(email)) {
document.getElementById('emailo2').innerHTML="";
document.getElementById('emailo1').innerHTML="";
}else {
document.getElementById('emailo2').innerHTML="invalid email address";
document.getElementById('emailo1').innerHTML="*";
flag=false;
}
//------------------------------------------------
if(sex0 || sex1 ){
document.getElementById('sexo2').innerHTML="";
document.getElementById('sexo1').innerHTML="";
}else{
document.getElementById('sexo2').innerHTML="Please select";
document.getElementById('sexo1').innerHTML="*";
flag=false;
}
//----------------------------------------------
if(day=="" || isNaN(day)){
flag=false;
document.getElementById('birthdayo2').innerHTML="fill please only numbers please";
document.getElementById('birthdayo1').innerHTML="*";
}else{
document.getElementById('birthdayo2').innerHTML="";
document.getElementById('birthdayo1').innerHTML="";
}
if(month=="" || isNaN(month)){
flag=false;
document.getElementById('birthdayo2').innerHTML="fill please only numbers please";
document.getElementById('birthdayo1').innerHTML="*";
}else{
document.getElementById('birthdayo2').innerHTML="";
document.getElementById('birthdayo1').innerHTML="";
//alert(month);
}
if(year=="" || isNaN(year) || year<1914 ||year>1996){
flag=false;
if(year<1914 ||year>1996)
{
document.getElementById('birthdayo2').innerHTML="invalid age";
}
else{
document.getElementById('birthdayo2').innerHTML="fill please only numbers";
document.getElementById('birthdayo1').innerHTML="*";
}
}else{
document.getElementById('birthdayo2').innerHTML="";
document.getElementById('birthdayo1').innerHTML="";
//alert(year);
}
return flag;
}
/* var reg =/^([a-zA-Z0-9_.-]) @([a-zA-Z0-9_.-]) \.([a-zA-Z]) ([a-zA-Z]) /;
if (reg.test(email)) {
document.getElementById("td7").innerHTML="";
}else {
document.getElementById("td7").innerHTML="<p style='color:red';>*Please provide a valid email address</p>";
flag=false;
}
*/