验证,提示
$(function () {
$("#fromAddPlatform").validate({
rules: {
PlatformCode: {
remote: {
type: "POST",
dataType: 'json',
url: '@Url.Action("Exist")',
data: {
code: function () { return $("#fromAddPlatform select[name='PlatformCode']").val(); }
}
}
},
Account: "required",
Pwd: {
required: true,
minlength: 5
},
PlatformUrl: {
required: function () { return $("#fromAddPlatform select[name='PlatformCode']").val() == "TTS" },
url: true
}
},
messages: {
PlatformCode: {
remote: jQuery.format("该用户已经注册{0}渠道")
},
Account: "账号不能为空",
Pwd: {
required: "密码不能为空",
minlength: jQuery.format("密码不能小于{0}个字符")
},
PlatformUrl: {
required: "推送地址必须填写",
url: "推送地址格式不正确"
}
}
});
}
提交:
if ($('#fromAddPlatform').valid()) {
}
推荐阅读:
http://blog.csdn.net/linewwei/article/details/8485036