-
Notifications
You must be signed in to change notification settings - Fork 0
/
caform.html
84 lines (79 loc) · 2.18 KB
/
caform.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
<!DOCTYPE html>
<html>
<head>
<title>Form validation Email</title>
<script>
function validate()
{
if(document.getElementById("t1").value=="")
{
alert("Please provide your name!");
document.getElementById("t1").focus();
return false;
}
var emailID=document.getElementById("t2").value;
atpos=emailID.indexOf("@");
dotpos=emailID.lastIndexOf(".");
if(document.getElementById("t2").value==""||atpos<1||(dotpos-atpos<2))
{
alert("Please enter correct email ID");
document.getElementById("t2").focus();
return false;
}
if(document.getElementById("t3").value=="")
{
alert("Please provide a zip code!");
document.getElementById("t3").focus();
return false;
}
if(document.getElementById("t4").value=="-1")
{
alert("Please provide your country!");
document.getElementById("t4").focus();
return false;
}
return(true);
}
</script>
</head>
<body>
<form name="myForm" onsubmit="return(validate());">
<table cellspacing="2" cellpadding="2" border="1">
<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">Zip Code</td>
<td><input type="text" name="Zip" id="t3"></td>
</tr>
<tr>
<td align="right">Country</td>
<td><select name="Country" id="t4">
<option value="-1" selected>[choose yours]</option>
<option value="1">USA</option>
<option value="2">UK</option>
<option value="3">INDIA</option>
</select>
</td>
</tr>
<tr>
<td align="right"></td>
<!--<td><input type="submit" name="Submit" onclick=windows.open("file:///C:/Users/user/Desktop/SEM%202/HTML%20programs/catest.html") /></td>-->
</tr>
<!--<p id="demo"></p>
<script>
function myFunction(){
document.getElementById("demo").innerHTML="YOU HAVE SUCCESSFULLY REGISTERED";
}
</script>
<button onclick="myFunction()">Submit</button>-->
</table>
<input type="submit" value="submit" onclick=window.open("file:///C:/Users/user/Desktop/SEM%202/HTML%20programs/caregisterd.html")>
</form>
</body>
</html>