0
votes

Lets say I have this function and I'm adding some errors manually:

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

When form is submitted first time, my custom error is added. Every thing works fine. My error is shown and form is not submitted.

But next time, my input is Valid!. looks like this invalid field is not persistence and input is Invalid only first time.

Is this the default behavior? Do I need to add my custom error every time the form is submitted?

By the way, there are no rules added to my input elements (beside some required field validation). No custom or remote rule.

1
No, that is not how it's supposed to work... you're doing something incorrectly. You have enough rep to know that you need to show enough code to make a working example. Have you read the documentation? Are you initializing the plugin properly? Where is the rendered HTML markup? What does "adding errors manually" mean? Are you talking about a custom rule or a custom message on a standard rule? - Sparky
@Sparky Cool down bro. Don't lynch me!. I've read the [the documentation] (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. The problem is answered! This should not work like this! - Afshin Gh
I never asked for "the whole thing"... I'm asking you to only show "enough code to make a working example" to demonstrate the issue. Since you're asking about the jQuery Validate plugin, that would have absolutely nothing to do with your database or framework... just some relevant rendered HTML and JavaScript. - Sparky

1 Answers

0
votes

You would need to call it every time the form is submitted I believe, or any time one of the fields is updated for a more immediate validation.