JS-input验证

    <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>