表单检查,表单提交前时间,手动触发表单检查
//手动触发表单检查
document.forms["myform"].reportValidity();
//https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reportValidity
//自定义提示语言
windows.onload = function() {
var p2 = document.forms["my_f1"].passwd2;
p2.oninvalid = function() {
this.setCustomValidity("密码不一致,请重新输入");
//reset
this.setCustomValidity("");
}
p2.oninput = function() {
this.setCustomValidity("");
}
}
$("#form").submit(function(e){
if(e.target.checkValidity()){
}
return false;
})