-
Notifications
You must be signed in to change notification settings - Fork 0
/
form valid2.html
48 lines (40 loc) · 937 Bytes
/
form valid2.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
<html>
<head>
<script type="text/javascript">
function validate()
{
var username=document.getElementById("uname");
var password=document.getElementById("pass");
if(username.value.trim()=="" )
{
alert("blank user name");
document.getElementById("label1").style.visibility="visible";
uname.style. border="solid 3px red";
return false;
}
else if(password.value.trim()=="" )
{
alert("blank password");
return false;
}
else if(password.value.trim().length<5)
{
alert("the password value is too short");
pass.style.border="3px solid red";
return false;
}
else{
return true;
}
}
</script>
</head>
<body>
<form onsubmit="return validate()" action="message.html">
<input type="text" id="uname" placeholder="Username" >
<label id="label1" style="visibility:hidden;color:red;">Invalid</label><br><br>
<input id="pass" type="password" name="pass" placeholder="password"><br><br>
<button type="submit">Submit</button>
</form>
</body>
</html>