2
我使用jQuery驗證插件和遠程屬性與emailId一起使用,但不與mobileNo?爲什麼jQuery驗證插件的遠程屬性對我無效?
var validator = $("#addform").validate({
rules: {
Name: "required",
MobileNo: {
required: true,
minlength: 10, remote: '<%=Url.Action("getClientMobNo", "Clients") %>'
},
Address: "required"
},
messages: {
Name: "please provide a client name",
MobileNo: {
required: "Please provide a mobile phone no",
rangelength: jQuery.format("Enter at least {0} characters"),
remote: jQuery.format("This MobileNo is already in use")
},
Address: "please provide client address"
},
一個null
值傳遞給我的控制器行動。任何建議...
public JsonResult getClientMobNo(string mobno)
{
JsonResult result = new JsonResult();
string status = clirep.getClientMobNo(Convert.ToInt64(mobno));
if (status == "Mobile No already exists")
{
result.Data = false;
}
else
{
result.Data = true;
}
return result;
}