常见的 JQuery 正则表达式以及验证方法 (2)

$("#name").blur(function(){ // 产品名称验证
var name = $(this).val();
if(name != ""){
var matchResult = name.match(pattern_chin);
if(matchResult != null){
$("#productName-validator-error").parent().show();
$("#productName-validator-error").text("请不要输入非英文字符");
}else{
$("#productName-validator-error").parent().hide();
}
}else{
$("#productName-validator-error").parent().show();
$("#productName-validator-error").text("产品名称不能为空");
}
});

2、var patter_money = /^\d{0,9}(\.\d{0,4})?$/;
$("#fobMinPrice").blur(function(){
var fobMinPrice = $(this).val();
var matchResult = patter_money.test(fobMinPrice);
if(!matchResult){
$(this).parents(".fob-list").nextAll("div:eq(0)").show();
}else{
$(this).parents(".fob-list").nextAll("div:eq(0)").hide();
}
});

3、var patter_INT = /^(0|[1-9]\d*)$/;

4、var patten_Int_Not_0 = /^[1-9]\d*$/;

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zwjxgg.html