-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
161 lines (115 loc) · 4.06 KB
/
script.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
//signup name validate
var uname=document.getElementById('uname');
uname.addEventListener('keyup', checkunamevalidity);
function checkunamevalidity(e){
var unameval=uname.value;
var validformat = /^[A-Za-z]+$/;
if(validformat.test(unameval)){
uname.classList.add('is-valid');
uname.classList.remove('is-invalid');
}
else{
uname.classList.add('is-invalid');
uname.classList.remove('is-valid');
}
}
//signup email validate
var inputEmail4=document.getElementById('inputEmail4');
inputEmail4.addEventListener('keyup', checkemailvalidity);
function checkemailvalidity(e){
var unameval=inputEmail4.value;
var validformat = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
if(validformat.test(unameval)){
inputEmail4.classList.add('is-valid');
inputEmail4.classList.remove('is-invalid');
}
else{
inputEmail4.classList.add('is-invalid');
inputEmail4.classList.remove('is-valid');
}
}
//////password check
var inputPassword4=document.getElementById('inputPassword4');
inputPassword4.addEventListener('keyup', checkemailvalidity);
function checkemailvalidity(e){
var unameval=inputPassword4.value;
var validformat = /^[A-Za-z]\w{7,14}$/;
if(validformat.test(unameval)){
inputPassword4.classList.add('is-valid');
inputPassword4.classList.remove('is-invalid');
}
else{
inputPassword4.classList.add('is-invalid');
inputPassword4.classList.remove('is-valid');
}
}
///////////////zip code
var inputZip=document.getElementById('inputZip');
inputZip.addEventListener('keyup', checkemailvalidity);
function checkemailvalidity(e){
var unameval=inputZip.value;
var validformat = /^[0-9]{4}$/;
if(validformat.test(unameval)){
inputZip.classList.add('is-valid');
inputZip.classList.remove('is-invalid');
}
else{
inputZip.classList.add('is-invalid');
inputZip.classList.remove('is-valid');
}
}
/////////loginEmail&pass
var exampleInputEmail1=document.getElementById('exampleInputEmail1');
exampleInputEmail1.addEventListener('keyup', checkemailvalidity);
function checkemailvalidity(e){
var unameval=exampleInputEmail1.value;
var validformat = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
if(validformat.test(unameval)){
exampleInputEmail1.classList.add('is-valid');
exampleInputEmail1.classList.remove('is-invalid');
}
else{
exampleInputEmail1.classList.add('is-invalid');
exampleInputEmail1.classList.remove('is-valid');
}
}
//////password check
var exampleInputPassword1=document.getElementById('exampleInputPassword1');
exampleInputPassword1.addEventListener('keyup', checkemailvalidity);
function checkemailvalidity(e){
var unameval=exampleInputPassword1.value;
var validformat = /^[A-Za-z]\w{7,14}$/;
if(validformat.test(unameval)){
exampleInputPassword1.classList.add('is-valid');
exampleInputPassword1.classList.remove('is-invalid');
}
else{
exampleInputPassword1.classList.add('is-invalid');
exampleInputPassword1.classList.remove('is-valid');
}
}
///////searchfield
var sf=document.getElementById('sf');
var sform=document.getElementById('sform');
sf.addEventListener('keyup', checkemailvalidity);
sform.addEventListener('keyup', checksearch);
function checkemailvalidity(e){
var unameval=sf.value;
var validformat = /^[A-Za-z-9]{3,}$/;
if(validformat.test(unameval)){
sf.classList.add('is-valid');
sf.classList.remove('is-invalid');
return true;
}
else{
sf.classList.add('is-invalid');
sf.classList.remove('is-valid');
return true;
}
}
function checksearch(e){
if(!checkemailvalidity())
{
e.preventDefault();
}
}