0

I noticed that validation occurs even when i am typing. What i would like is that it only performs validation when another field is selected or when clicked on the submit button.

Is there a way to prevent validation when typing?

Jamie
  • 3,031
  • 5
  • 36
  • 59
  • Which control is performing the validation? Client-side validation is exclusively performed using javascript, so you should inspect the js you are sending to the browser to find the culprit and disable it. – Guillaume CR Sep 29 '14 at 13:42
  • @GuillaumeCR ASP.MVC automatically performs client side validation when you enable validation and included the necessary scripts. No manual activation is required. – Jamie Sep 29 '14 at 13:51
  • @jamie, you need to turn it off in web.config – Rex Sep 29 '14 at 13:57
  • this may help: http://stackoverflow.com/a/14316783/1385075 – Marian Ban Sep 29 '14 at 14:14

1 Answers1

2

If you want to disable as-you-type validation for all fields, try doing this:

$(function(){
    $.validator.setDefaults({
       onkeyup: false    // disable onkeyup events
    });
});
Mrchief
  • 75,126
  • 20
  • 142
  • 189
  • This works, thanks. I do have to note that i had to put this code in front of my validate and validate unobtrusive scripts. – Jamie Sep 29 '14 at 15:27
  • Yeah, you need to run this before unobtrusive validation kicks in! :) – Mrchief Sep 29 '14 at 15:42