現在H5的input標簽提供了大量的內置的驗證,在表單提交時驗證.而且可以通過js做一些自定義比如:$("#form").submit(function(e){ if(e.target.checkValidity()){//是否驗證通過 } return false;})//自定義提示語言windows.onload = function() { var p2 = document.forms["my_f1"].passwd2; p2.oninvalid = function() { this.setCustomValidity("密碼不一致,請重新輸入"); //reset this.setCustomValidity(""); } p2.oninput = function() { this.setCustomValidity(""); } }//手動觸發表單檢查document.forms["myform"].reportValidity();請問是否有基于H5原生驗證的插件(不依賴JQuery)
尋求基于HTML5內置驗證方式的Js代碼段或插件
楊__羊羊
2018-11-23 19:14:20