作者:安仔小窝forever | 来源:互联网 | 2023-09-11 15:21
写表单验证时把每个验证都写的是inputonblur事件,出现一个问题,如果用户直接按那个a标签提交就不走每个inputonblur事件,难道我要重新写每个事件吗?跟
写表单验证时把每个验证都写的是input onblur事件,
出现一个问题,如果用户直接按那个a标签提交就不走每个input onblur事件,
难道我要重新写每个事件吗?
跟怎样给这个a标签加个点击事件?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| $("#phone_code").on("blur",function(){
if($(this).val() == ""){
$(this).next(".error").css("display","inline-block");
$(this).parent().find(".success").css("display","none");
$(this).parent().find(".info_tips").text("不能为空").css("color","#FF0000");
}
else if(!phone_code_reg.test($(this).val())){
$(this).parent().find(".success").css("display","none");
$(this).next(".error").css("display","inline-block");
$(this).parent().find(".info_tips").text("输入的短信验证码格式不正确").css("color",
"#FF0000");
}
else{
$(this).parent().find(".error").css("display","none");
$(this).parent().find(".success").css("display","inline-block");
$(this).parent().find(".info_tips").text("");
}
});
.... |