Home >Web Front-end >H5 Tutorial >The required attribute of the input element is invalid
Safari does not support the required attribute of input, which can be solved with js
$(document).ready(function(){ $("form").submit(function(e) { var ref = $(this).find("[required=required]"); alert('ref'); $(ref).each(function(){ if ( $(this).val() == '' ) { alert("Required field should not be blank."); $(this).focus(); e.preventDefault(); return false; } }); return true; }); });
For more related articles about the invalid required attribute of input elements, please pay attention to the PHP Chinese website!