Confirm filled jQuery form (not valid the first time a field is cleared, ASP.NET and non-intrusive)

I have a form that can be filled out, saved, loaded and edited.

When it is downloaded and republished, it probably begins its life. When the field is valid at loading, I want it to be immediately invalidated when it was edited contrary to the rules. What is my question in a nutshell, and I suspect that this is supported by some configuration options, I cannot find.


Currently, it works correctly (as was said above) only after: 1) it has been edited, 2) then the field loses focus while it is valid, 3) then it is edited again. Therefore, in order to visualize errors for a pre-filled form, an additional actual loss of focus is required.

If it is empty at boot (for example, the first visit), it should not show errors.

I already use the following in my structure:

  • jQuery.validate ("approved" and the main question of my question)
  • jQuery unobtrusive validation adapter for ASP.NET MVC 3

I am not currently running any custom code since the “unobtrusive” adapter initiates the check (but I would be happy to fix this). I tried adding 'form.valid ()' to the page load, but it does not fix the above and actually breaks more stuff.

Thanks, Shannon

+3
source share
3 answers

I dug up a validation plugin and opened a ticket for what, in my opinion, is a defect.

https://github.com/jzaefferer/jquery-validation/issues/146

Shannon

+1
source

You can try to check the form manually every time the input has been changed.

$(":input").live("change", function(){
    form.validate();
})

, form.valid(), form.validate();.

0

This constructor works for me:

$('form').validate({
    onfocusout: function(element) {
       this.element(element);
    }, ...
});
0
source

All Articles