开发者

Why doesn't jquery validation plugin's remote attribute work for me?

I use jquery validation plugin and the remot开发者_运维问答e attribute works with emailId but not with 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"
       },

A null value is passed to my controller action.. Any suggestion...

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


The variable names aren't matching up. JQuery is passing a parameter of MobileNo, but your function is looking for mobno. Change your function to accept the parameter MobileNo, and you'll get your value.

public JsonResult getClientMobNo(string MobileNo)
{
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜