Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. AWS
  3. Question
AWS

Jquery validator with javascript remoting

Asked by Elvera Peasley Jul 12, 2021 1.3K views 1 answer
Share

About this question

I have an input field out of several on a form, whose value needs to be validated against database values. I am using jquery validator to perform all other validations and trying to achieve database validation using visualforce remoting and validator method. What I am trying.

HTML Code

<input type="text" class="numVal" maxlength="6" "="" fdprocessedid="4nf8uh">

Validator Rule class and method snippet
$j.validator.addClassRules({ numVal: { required: true, number: true, noDecimal:true, checkDBList: true } }); $j.validator.addMethod("checkDBList",function(value) { MyController.searchDB(value, function(result, event){ if(event.status ){ if(result != null){ return true; }else{ return false; } } if(event.type == 'exception') { return false } }); }, "Please enter a valid number");

Problem My validator method is always returning false, even though a valid number is provided and the remote method is returning the correct status. I understand that visualforce remoting is asynchronous and both the functions are executing in different contexts and hence the issue. Any help to use the visualforce remoting in a correct way inside the validator method is appreciated.

Your answer

1 Answer

More AWS discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest AWS Blogs

Guides, tips and career advice on AWS from JanBask experts.