jquery实现用户信息修改验证输入方法汇总

2020-05-19 07:39:57易采站长站整理

$("#cardNum").focus(function(){ check_cardNum();});
$("#cardNum").blur(function(){ check_cardNum();});

$("#passWord").focus(function(){ check_passWord();});
$("#passWord").blur(function(){ check_passWord();});

$("#vcode").focus(function(){ check_vcode(); });
$("#vcode").blur(function(){ check_vcode(); });
$("#formsubmit").click(function(){
$("#strmsg").hide();
$("#numMsg").html("");
$("#psMsg").html("");
$("#vcodeMsg").html("");
var re= /^[0-9]*$/;
if(cardnumFlag != 0 || $.trim($("#cardNum").val()) == "" || $("#cardNum").val() == null )
{
$("#cardNum").focus();
return ;
}
if(passwordFlag != 0 || $.trim($("#passWord").val()) == "" || $("#passWord").val() == null)
{
$("#passWord").focus();
return ;
}
if(($("#vcode").val() != "" && !re.test($("#vcode").val())) || vcodeFlag != 0 || $("#vcode").val() == "" )
{
$("#vcode").focus();
return ;
}
$("#cardform").submit();
});
/**** ---------卡查询表单提交验证 end ***********/

//用户订单取消,
$("#cancelreason").focus(function(){
$("#errorinfo").html("");
$("#errorinfo").removeClass("tips");
});

$("#cancelreason").bind('input propertychange', function() {
var maxLength = 65;
if ($(this).val().length > maxLength) {
$(this).val($(this).val().substring(0, maxLength));
}
return false;
})
//-----

});
//end ready
//修改用户信息表单提交
function formsubmit()
{
$("#showSpan").hide();
var province=$("#province").val();
var city=$("#city").val();
var region=$("#region").val();
$("#emailMsg").html("");
$("#realnameMsg").html("");
$("#cellphoneMsg").html("");
$("#homephoneMsg").html("");
$("#szcode").html("");
$("#addressMsg").html("");
$("#zipMsg").html("");
if(emailFlag != 0 || $("#email").val()== null || $("#email").val()== "")
{
$("#email").focus();
return ;
}
if(realnameFlag != 0 || $("#realname").val()== null || $("#realname").val()== "")
{
$("#realname").focus();
return ;
}
if($("input[name=sex]:checked").val()==null||$("input[name=sex]:checked").val()==""){
alert("请选择性别");
$("#sex").focus();
return;
}
if(cellphoneFlag != 0)
{
$("#cellphone").focus();
return ;
}
if(homephoneFlag != 0)
{
$("#homephone").focus();
return ;
}
if( province == "" || city == "" || region== "" || province == null || city == null || region== null)
{
$("#szcode").html("<span class='tips'>请选择地区</span>");
return ;
}
if(addressFlag != 0 || $("#address").val() == null || $("#address").val() == "")
{
$("#address").focus();