$("#inputForm").validate({
rules: {
strategyTypeId: {
remote:{
url: "${ctx}/asset/checkAssetName?nocache=" + new Date().getTime(), //後臺處理程序
type: "post", //數據發送方式
dataType: "json", //接受數據格式
data: { //要傳遞的數據
strategyTypeId: function() {
return $("#strategyTypeId").val(); //要驗證的值
},assetIP: function() {
return $("#assetIP").val(); //要驗證的值
}
}
}
},
assetIP: {
ip:true,
remote:{
url: "${ctx}/asset/checkAssetName?nocache=" + new Date().getTime(), //後臺處理程序
type: "post", //數據發送方式
dataType: "json", //接受數據格式
data: { //要傳遞的數據
strategyTypeId: function() {
return $("#strategyTypeId").val();
},assetIP: function() {
return $("#assetIP").val();
}
}
},
assetMeid:{
isMeid:true,
remote:{
url: "${ctx}/asset/checkAssetMeid?nocache=" + new Date().getTime(), //後臺處理程序
type: "post", //數據發送方式
dataType: "json", //接受數據格式
data: { //要傳遞的數據
strategyTypeId: function() {
return $("#assetMeid").val();
},assetId: function() {
return ${asset.id};
}
}
}
},
confirmpassword: {
equalTo: "#password",
}
},
messages: {
assetName:{
required: "請填寫資產名稱 ",
},
strategyTypeId: {
<span style="white-space:pre"> </span>required: "請選擇資產類型 ",
remote: "資產已存在"
},
strategyId:{
required: "請選擇策略名稱 ",
},
assetIP: {
required: "請輸入資產IP",
remote: "資產已存在",
ip:"請輸入正確的IP地址,如:192.168.01.01",
},
assetMeid: {
required: "請輸入MEID",
remote: "MEID已存在",
isMeid:"輸入的MEID不正確,請輸入14位或15位十六進制數",
},
scanType:{
required: "請選擇掃描方式 ",
},
loginType:{
required: "請選擇登錄類型 ",
},
loginName:{
required: "請填寫登錄名稱 ",
},
password:{
required: "請填寫登錄密碼 ",
},
confirmpassword: {
required: "請再次輸入登錄密碼 ",
equalTo:"兩次登錄密碼輸入不一致,請重新輸入 ",
}
}
JQuery Validate自帶驗證例子
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.