52,792
社区成员




$("#typeId").formValidator({onShow:"请选择产品分类",onFocus:"请选择产品分类",onCorrect:"产品分类已选择"}).inputValidator({min:1,onError: "必须选择产品分类"});
$("#productModel").formValidator({onShow:"请输入产品型号", onFocus:"请输入非空字符", onCorrect:"产品型号输入正确"}).regexValidator({regExp:"notempty",dataType:"enum",onError:"输入的产品型号格式不正确"}).inputValidator({min:3, max:30, onError:"输入的产品型号长度不正确"}).ajaxValidator({
type:"post",
dataType: "html",
async: false,
url: basePath + "product/verifyProModel.do",
data:{"pro.typeId" : function(){return $("#typeId").val();}},//注:此处本来的需要验证的属性值就不用传值了,否则会出现重复值
success : function(data){
if(data == "0") return true;
return "该产品型号已存在,请更换产品型号";
},
buttons: $("#button1"),
error: function(jqXHR, textStatus, errorThrown){$.dialog.alert("服务器未响应,请重试"+errorThrown, function(){});},
onError: "该产品型号不可用,请更换产品型号",
onWait: "正在进行合法性校验,请稍候..."
});
==================================================
<s:select list="proTypeList" id="typeId" name="pro.typeId" listKey="id" listValue="typeName" ></s:select>
<s:textfield name="pro.productModel" id="productModel" ></s:textfield>
data:{"diyUserCollocate.id":function(){
return _this.val();
},
"diyUserCollocate.type" : function(){
return _this.attr("name").split("_")[1];
}
}
$.formValidator.initConfig({formID:"myform",debug:false,submitOnce:false,
ajaxObjects:'#data_customer_cate,#mid',
initConfig.ajaxObjects = ajax + (ajax != "" ? ",#" : "#") + this.id;