forked from lixinso/html5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom_error.html
More file actions
26 lines (25 loc) · 822 Bytes
/
custom_error.html
File metadata and controls
26 lines (25 loc) · 822 Bytes
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
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Custom Error Check Sample</title>
<script language="javascript">
function check()
{
var pass1 = document.getElementById("pass1");
var pass2 = document.getElementById("pass2");
if(pass1.value != pass2.value)
pass2.setCustomValidity("Password is inconsistant");
else
pass2.setCustomValidity("");
var email = document.getElementById("email");
if(!email.checkValidity())
email.setCustomValidity("Please input the right email");
}
</script>
<form id="testform" onSubmit="return check();">
Pasword: <input type=password name="pass1" id="pass1"/><br/>
Confirm Password: <input type=password name="pass2" id="pass2"/><br/>
Email: <input type=email name="email1" id="email"/><br/>
<input type="submit" />
</form>
</head>