The strange phenomenon of the oninvalid event!

oninvalid event, which is triggered when the input tag check is invalid, and prompts an error message

.

it is strange that when there is more than one input in form, you can block error messages in the following ways:


    </div>
</form>

<script>
var form = document.querySelectorAll( "form" )[0];

form.addEventListener( "invalid", function( event ) {
    event.preventDefault();
},true);

form.oninvalid=function(e){
    return false;
}    
    
</script>
    
</body>
</html>
Mar.15,2021
Menu