forked from naveenbadhan27/morning8-30
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10.html
More file actions
116 lines (75 loc) · 2.47 KB
/
10.html
File metadata and controls
116 lines (75 loc) · 2.47 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
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form onsubmit="">
<input type="submit" name="">
</form>
<form id="myform">
<br>
<input type="text" id="name" onkeyup="check()" autofocus placeholder="Fill your name"><br>
<input type="text" id="email" onkeyup="check()" placeholder="Fill your email"><br>
<input type="text" id="contact" onkeyup="check()" placeholder="Fill your contact"><br>
<input type="button" onclick="formsubmit()" value="Submit">
</form>
<script type="text/javascript">
function check(){
var x = event.which || event.keyCode;
// console.log(x);
if (x == 13) {
formsubmit();
}
}
function formsubmit(){
var na = document.getElementById('name').value;
var em = document.getElementById('email').value;
var ct = document.getElementById('contact').value;
var check_na = /^[A-Za-z ]+$/;
var check_em = /^[a-z][a-z0-9_]+[a-z0-9]+[@][a-z]+[.][a-z]{2,5}[.a-z]*$/;
var check_ct = /^[0-9]{10}$/;
if (na == '') {
alert('Please fill name field');
document.getElementById('name').focus();
}else if(em == ''){
alert('Please fill email field');
document.getElementById('email').focus();
}else if(ct == ''){
alert('Please fill contact field');
document.getElementById('contact').focus();
}else if(!check_na.test(na)){
alert('Please fill Alpha only');
document.getElementById('name').focus();
}else if(!check_em.test(em)){
alert('Please fill valid email');
document.getElementById('email').focus();
}else if(!check_ct.test(ct)){
alert('Please fill valid contact');
document.getElementById('contact').focus();
}else{
alert('Form Submitted');
document.getElementById('myform').reset();
}
}
var names = ["Red","Blue","Green","Yellow"];
// var name = [1, 5, 8, 6, 1];
// document.write(names[0]);
for (var i = 0; i < names.length; i++) {
document.write(names[i]+'<br>');
}
var date = new Date();
document.write(date+'<br>');
document.write(date.getDate()+'<br>');
document.write(date.getMonth()+1+'<br>');
document.write(date.getFullYear()+'<br>');
document.write(date.getDate()+'-'+(date.getMonth()+1)+'-'+date.getFullYear()+'<br>');
document.write('<br>');
document.write(Math.PI);
document.write('<br>');
document.write(Math.random());
document.write('<br>');
document.write(Math.floor(Math.random()*10000));
</script>
</body>
</html>