-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormValidate.html
More file actions
58 lines (46 loc) · 1.41 KB
/
Copy pathFormValidate.html
File metadata and controls
58 lines (46 loc) · 1.41 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
<html>
<head>
<title>Form Validate</title>
<h1>FORM VALIDATE</h1>
<script type="text/javascript">
function func1()
{
var uname = document.getElementById("name")
var upass = document.getElementById("pass")
if(uname.value.trim() =="")
{
alert("blank username")
uname.style.border = "solid 3px red"
//return false beacuse then redirect to the next page will not happen
return false
}
else if(upass.value.trim() =="")
{
alert("blank password")
upass.style.border = "solid 3px red"
return false
}
else if (uname.value.trim().length <5)
{
alert("short password")
return false
}
else
{
true
}
}
</script>
</head>
<body>
<form onsubmit=" return func1()" action="Massage.html">
<input id="name" type="text" placeholder="enter your name">
<br>
<br>
<input id="pass" type="password" placeholder="enter your password">
<br>
<br>
<button type="submit">SUBMIT</button>
</form>
</body>
</html>