i am using remote validation. i want to validate weather the phone no is exist or not. But Remote method does not called. I have seen some of solution they were adding jquery validate cdn for remote validation. I have put these cdn but still problem exists. here is code.
<head>
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="" href="https://cdnjs.cloudflare.com/ajax/libs/validate-js/2.0.1/validate.min.js" />
<link rel="" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-validation-unobtrusive/3.2.6/jquery.validate.unobtrusive.min.js" />
<title>Index</title>
</head>
<form name="frmCreateList" method="post" action="@Url.Action("Index","Home")">
<div class="form-group">
<div class="row">
<div class="col-md-4">
<span><b>Employee Phone</b></span>
</div>
<div class="col-md-8">
@Html.TextBoxFor(x => x.EmpPhone, new { @class = "form-control" })
@Html.ValidationMessageFor(x => x.EmpPhone,"", new { @class="text-danger" })
</div>
</div>
</div>
</form>
<button type="submit" class="btn btn-primary">Submit</button>
Here is model.
[Required(ErrorMessage ="Please Enter Phone")]
[Remote("CheckPhoneNumber","Validation","Phone number already exists")]
public string EmpPhone { get; set; }
Here is Remote Method in controller.
[AllowAnonymous]
public JsonResult CheckPhoneNumber(string EmpPhone)
{
var record = _listEmp.SingleOrDefault(x => x.EmpPhone == EmpPhone);
if(record != null)
{
return Json(false, JsonRequestBehavior.AllowGet);
}
else
{
return Json(true, JsonRequestBehavior.AllowGet);
}
}