-
Notifications
You must be signed in to change notification settings - Fork 10
/
validation.html
96 lines (95 loc) · 4.08 KB
/
validation.html
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
<!DOCTYPE=html>
<html>
<head>
<title> validation</title>
<script>
function validate()
{
var a,b,x;
a=document.getElementById("t4").value;
b=document.getElementById("t5").value;
x=document.getElementById("t3").value;
if(x==""||isNaN(x)||x.length!=7)
{
alert("please enter 7 digit code");
document.getElementById("t3").focus();
return false;
}
if(a!=b)
{
alert("please correct your password");
document.getElementById("t5").focus();
return false;
}
var email=document.getElementById("t2").value;
atpos=email.indexof("@");
dotpos=email.indexof(".");
if(document.getElementById("t2").value==""||atpos<1||(dotpos-atpos<2))
{
alert("please enter correct email")
document.getElementById("t2").focus();
return false;
}
if(document.getElementById("t1").value=="")
{
alert("please provide your name");
document.getElementById("t1").focus();
return false;
}
if(document.getElementById("t3").value=="")
{
alert("please enter your zip code")
document.getElementById("t3").focus();
return false;
}
if(document.getElementById("t6").value=="")
{
alert("please enter country");
document.getElementById("t6").focus();
return false;
}
}
</script>
</head>
<body>
<form name="my form " onsubmit="return(validate());">
<table cellspacing="4"cellpadding="4" border="2">
<tr>
<td align="right">name</td>
<td><input type="text" name="name" id="t1" /></td>
</tr>
<tr>
<td align="right">email</td>
<td><input type="text" name="email" id="t2"/></td>
</tr>
<tr>
<td align="right">zipcode</td>
<td><input type="text" name="zipcode" id="t3"/></td>
</tr>
<tr>
<td align="right">password</td>
<td><input type="password" name="password" id="t4"/></td>
</tr>
<tr>
<td align="right">re-password</td>
<td><input type="password" name=" re-password" id="t5"/></td>
</tr>
<tr>
<td align="right">country</td>
<td>
<select name="country" id="t6">
<option value="-1" selected>[choose yours]</option>
<option value="1" selected>USA</option>
<option value="2" selected>UK</option>
<option value="3" selected>INDIA</option>
</select>
</td>
</tr>
<tr>
<td align="right"></td>
<td><input type="submit" value="submit"/></td>
</tr>
</table>
</form>
</body>
</html>