Checking from database using json and Controler's action where controler is Validation and Action is CheckPanNo . Then we check format using test function. and error message set to messages section of kendoValidator function.
Java Script
///Pan No Duplication checking
var validatable = $("#Pan").kendoValidator({
onfocusout: true,
onkeyup: true,
rules: {
PanNo: function (input) {
$.post("/Validation/CheckPanNo",
{ PanNo: $("#Pan").val() }, function (data) { b1 = data; })
return b1;
},
PanFormat: function (input) {
// return validatePanCard('Pan');
var value = input.val();
var regex1 = /^[A-Z]{5}\d{4}[A-Z]{1}$/;
if (!regex1.test(value) || value.length
!= 10) {
return false;
}
return true;
}
},
messages: {
PanNo: "Already Exist",
PanFormat: "Not a currect format"
}
}).data("kendoValidator");
Action
[HttpPost]
public JsonResult
CheckPanNo(string PanNo)
{
bool IsOk = projectRepository.CheckPanNumber(PanNo);
return Json(IsOk, JsonRequestBehavior.AllowGet);
}
No comments:
Post a Comment