0

I have a drop down in my form.

I don't want my form to be submitted when a particular item in my dropdown is selected (based on some remote logic that I'm handling manually using some Ajax calls).

I prefer not to use jQuery validation remote rule, because of it's async nature (some times form is submitted when the remote rule is still working: Using jQuery validator's valid() or element() method with remote methods).

Where should I start? Do I need to add a custom rule?

jQuery Validate Plugin - How to create a simple custom rule?

or just adding my errors is sufficient?

$('form').validate().showErrors({
  "firstname": "I know that your firstname is Pete, Pete!"
});

or something else?

Community
  • 1
  • 1
Afshin Gh
  • 7,918
  • 2
  • 26
  • 43
  • *"Where should I start?"* : By reading [the documentation](http://jqueryvalidation.org/) and trying something. Then show us enough code to reproduce the problem if/when you get stuck. As it stands, your question is incredibly broad and lacking enough relevant code. Yes, if the rule is not already built into the plugin, use `.addMethod()` to write your own. – Sparky May 09 '15 at 03:03
  • @Sparky Cool down bro. Don't lynch me!. I've read the [the documentation] (http://jqueryvalidation.org/). My project is being developed using Asp.ne MVC, WebAPI, MS Sql, KnockoutJS, etc, I have a little problem with jQuery validation. Posting the whole thing is not going to do any good. My problem is with 'showErrors()' not working as expected. I just want some outer perspective regarding my problem. – Afshin Gh May 09 '15 at 21:59

0 Answers0