-
var validateResult;
-
-
function validate_form(){
-
//自定义验证方法
-
$.validator.addMethod( "illegalStrCheck",function(value,element){
-
var regexStr = /^[\u4e00-\u9fa5a-zA-Z0-9_!#&+-=|@]{1,}$/;
-
if (!regexStr.test(value)) {
-
return false;
-
}
-
return true;
-
} ,"楼层名字包含非法字符");
-
-
$.validator.addMethod( "floorNameRepeatCheck",function(value,element){
-
var floor_name_repeat_tag=false;
-
$(".floor_tbl span").each(function(){
-
if($.trim($(this).html())==value){
-
floor_name_repeat_tag=true;
-
}
-
});
-
if(floor_name_repeat_tag){
-
return false;
-
}
-
return true;
-
} ,"楼层名字不允许重复");
-
-
validateResult=$("#uploadform").validate({
-
rules: {
-
floor_name: {
-
required: true,
-
maxlength: 128,
-
illegalStrCheck: true,
-
floorNameRepeatCheck :true
-
}
-
},
-
messages: {
-
floor_name: {
-
required: "网络名称不可为空",
-
maxlength: "楼层名字支持最多128个字符",
-
illegalStrCheck: "楼层名字包含非法字符",
-
floorNameRepeatCheck: "楼层名字不允许重复"
-
}
-
},
-
errorPlacement:function(error,element) {
-
error.appendTo(element.next().next("span"));
-
}
-
});
-
}
function submitForm(){
if(validateResult.form()){
********提交*****
}
}