-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.js
More file actions
289 lines (266 loc) · 10.5 KB
/
jquery.js
File metadata and controls
289 lines (266 loc) · 10.5 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
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
$(document).ready(function(){
$('#fnameval').hide();
$('#emailval').hide();
$('#conval').hide();
$('#contval').hide();
$('#countval').hide();
$('#statval').hide();
$("#userval").hide();
$("#passval").hide();
$("#cpassval").hide();
var fname_err=true;
var email_err=true;
var con_err=true;
var count_err=true;
var countcode_err=true;
var stat_err=true;
var img_err=true;
var usern_err=true;
var pass_err=true;
var cpass_err=true;
// for Full Name validation
$('#fname').keyup(function(){
fname_check();
});
function fname_check(){
var fname_in=$('#fname').val();
if (fname_in=='') {
$('#fnameval').show();
$('#fnameval').html('**Please Fill Your Full Name');
$('#fnameval').focus();
$('#fnameval').css("color","red");
fname_err=false;
return false;
}
else if ((fname_in.length< 3 )||(fname_in.length> 12 )) {
$("#fnameval").show();
$("#fnameval").text("***Name must be contain between 3 to 12 character");
$("#fnameval").focus();
$("#fnameval").css("color","red");
fname_err=false;
return false;
}else{
$("#fnameval").hide();
fname_err=true;
return true;
}
}
// for Email validation
$('#email').keyup(function(){
email_check();
});
function email_check(){
var email = $("#email").val();
if (email=='') {
$('#emailval').show();
$('#emailval').text("***This Field is required");
$('#emailval').focus();
$('#emailval').css("color","red");
email_err=false;
return false;
}else if(email != ''){
$("#emailval").show();
if(isValidEmailAddress(email))
{
$("#emailval").css("color","green");
$("#emailval").text("email is valid");
email_err=true;
return true;
} else {
$("#emailval").css("color","yellow");
$("#emailval").text("email is invalid");
email_err=false;
return false;
}
}
}
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
// console.log(pattern.test(emailAddress));
return pattern.test(emailAddress);
}
// for Username validation
$("#usern").keyup(function(){
usern_check();
})
function usern_check(){
var usercheck=$("#usern").val();
if (usercheck=='') {
$("#userval").show();
$("#userval").text("***This Fiel is mandatory");
$("#userval").focus();
$("#userval").css("color","red");
usern_err=false;
return false;
}else{
$("#userval").hide();
usern_err=true;
return true;
}
}
// for Password validation
$("#pass").keyup(function(){
password_check();
});
function password_check(){
var passcheck=$("#pass").val();
if ((passcheck=='') || (passcheck.length< 4 )||(passcheck.length> 8 )) {
$("#passval").show();
$("#passval").text("***Password must contain between 4 to 8 character");
$("#passval").focus();
$("#passval").css("color","red");
pass_err=false;
return false;
}else{
$("#passval").hide();
pass_err=true;
return true;
}
}
// for Confirm Password validation
$("#cpass").keyup(function(){
cpassword_check();
});
function cpassword_check(){
var passcheck=$("#pass").val();
var cpasscheck=$("#cpass").val();
if (cpasscheck!=passcheck) {
$("#cpassval").show();
$("#cpassval").text("***Confirm Password not match");
$("#cpassval").focus();
$("#cpassval").css("color","red");
cpass_err=false;
return false;
}else{
$("#cpassval").hide();
cpass_err=true;
return true;
}
}
// for mobile number validation
$("#contactno").keyup(function(){
contact_check();
})
function contact_check(){
var concheck=$("#contactno").val();
if (concheck.length=='' || concheck.length!=10) {
$("#conval").show();
$("#conval").text("***Invalid Mobile number");
$("#conval").focus();
$("#conval").css("color","red");
con_err=false;
return false;
}else{
$("#conval").hide();
con_err=true;
return true;
}
}
// for Country code validation
$("#countcode").change(function(){
countcode_check();
});
function countcode_check(){
var valcountcode=$('#countcode').val();
if(valcountcode=='0'){
$('#contval').show();
$('#contval').text("*****This Field is required");
$('#contval').focus();
$('#contval').css("color","red");
countcode_err=false;
return false;
}else{
$('#contval').hide();
countcode_err=true;
return true;
}
}
// for Country validation
$("#country").change(function(){
country_check();
});
function country_check(){
var countryval=$('#country').val();
if(countryval=='0'){
$('#countval').show();
$('#countval').text("*****This Field is required");
$('#countval').focus();
$('#countval').css("color","red");
count_err=false;
return false;
}else{
$('#countval').hide();
count_err=true;
return true;
}
}
// for State validation
$("#state").change(function(){
state_check();
});
function state_check(){
var countryval=$('#state').val();
if(countryval=='0'){
$('#statval').show();
$('#statval').text("***This Field is required");
$('#statval').focus();
$('#statval').css("color","red");
count_err=false;
return false;
}else{
$('#statval').hide();
count_err=true;
return true;
}
}
// for Image validation
$("#image").change(function(){
image_check();
});
function image_check(){
var val = $("#image").val();
if (!val.match(/(?:gif|jpg|png|bmp)$/)) {
$('#imgval').show();
$('#imgval').text("***please use ther jpg gif png bmp format image");
$('#imgval').focus();
$('#imgval').css("color","red");
img_err=false;
return false;
}else{
$('#imgval').hide();
img_err=true;
return true;
}
}
// for Final Submit validation
$('#sub-btn').click(function(event){
var fname_err=true;
var email_err1=true;
var con_err1=true;
var count_err1=true;
var countcode_err1=true;
var stat_err1=true;
var img_err1=true;
var usern_err1=true;
var pass_err1=true;
var cpass_err1=true;
fname_err1 = fname_check();
email_err1 = email_check();
con_err1 = contact_check();
count_err1 = countcode_check();
countcode_err1 = country_check();
stat_err1 = state_check();
img_err1=image_check();
usern_err1=usern_check();
pass_err1=password_check();
cpass_err1=cpassword_check();
var check_validation = (fname_err1==true) && (email_err1==true) && (usern_err1=true) && (pass_err1==true)
&& (cpass_err1==true) &&(con_err1==true) && (count_err1==true) && (countcode_err1==true) && (stat_err1==true) && (img_err1==true);
if (check_validation) {
return true;
}else{
event.preventDefault();
return false;
}
});
});