为什么jquery验证插件远程属性对我不起作用?

时间:2010-05-19 18:13:07

标签: jquery jquery-validate attributes

我使用jquery验证插件,远程属性适用于emailId但不适用于mobileNo?

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;
    }

1 个答案:

答案 0 :(得分:0)

变量名称不匹配。 JQuery传递的是MobileNo的参数,但是你的函数正在寻找mobno。更改您的功能以接受参数MobileNo,您将获得您的价值。

public JsonResult getClientMobNo(string MobileNo)
{