Ajax validation not working in jquery validation engine -
Ajax validation not working in jquery validation engine -
i new jquery validation engine , using validation of itemno in asp.net mvc application. using next code in view:
@html.textboxfor(model => model.itemno, new { @class="validate[required,ajax[ajaxcheckitemno]]" })
following code in jquery.validationengine-en.js
"ajaxcheckitemno": { // remote json service location "url": "/drugmanager/isitemnoalreadyexists", "extradatadynamic": ['#itemno'], // error "alerttext": "* name taken", // if provide "alerttextok", show greenish prompt when field validates "alerttextok": "* name available", // speaks "alerttextload": "* validating, please wait" }
and next code in controller
[httpget] public jsonresult isitemnoalreadyexists(string itemno, int drugid = 0, bool isaddform = true) { bool? returnvalue = null; seek { /* returns true/false */ returnvalue = objdrugmanager.isitemnoalreadyexists(itemno, drugid, isaddform); } grab (exception ex) { /* grab exception here */ } homecoming json(new { returnvalue });
when run code break comes server code returns value on view loading message display this
public jsonresult isitemnoalreadyexists(string itemno, int drugid = 0, bool isaddform = true) { bool? returnvalue = null; arraylist validationresult = new arraylist(); validationresult.add("itemno"); seek { /* returns true/false */ returnvalue = objdrugmanager.isitemnoalreadyexists(itemno, drugid, isaddform); if(returnvalue ==false) { validationresult.add(returnvalue ); validationresult.add("error message."); } else{ validationresult.add(returnvalue); validationresult.add("success message"); } } grab (exception ex) { /* grab exception here */ } homecoming json(validationresult, jsonrequestbehavior.allowget }); }
jquery ajax asp.net-mvc jquery-validation-engine
Comments
Post a Comment