-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputFieldEmailValidationExample01.htm
More file actions
executable file
·37 lines (34 loc) · 1.49 KB
/
Copy pathInputFieldEmailValidationExample01.htm
File metadata and controls
executable file
·37 lines (34 loc) · 1.49 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
<!DOCTYPE html>
<html>
<head>
<title>Input Field Email Example</title>
<script type="text/javascript" src="EventUtil.js"></script>
</head>
<body>
<p>Try submitting the following form without entering an email address. This only works in HTML5-compliant browsers.</p>
<script>
(function(){
var message = "Your browser does not support the email input type.",
input = document.createElement("input");
input.type = "email";
if (input.type=="email"){
message = "Your browser supports the email input type";
}
document.write("<p>" + message + "</p>");
})();
</script>
<form method="post" action="javascript:alert('Form submitted!')" id="myForm">
<label for="email">Email:</label> <input type="email" name="email" id="email" required>
<input type="submit" value="Submit Form"><br>
<input type="button" value="Check Validity" id="btnCheck"><input type="button" value="Will Validate?" id="btnWill">
</form>
<script>
EventUtil.addHandler(document.getElementById("btnCheck"), "click", function(event){
alert(document.forms[0].elements[0].checkValidity());
});
EventUtil.addHandler(document.getElementById("btnWill"), "click", function(event){
alert(document.forms[0].elements[0].willValidate);
});
</script>
</body>
</html>