I currently use Ajax to validate my form by checking each field "onblur" (meaning when user tabs out of the field or deselects it by clicking outside of it).
Hence it would not make sense to send and validate all fields again when I press submit button.
So all the submit button does is call a method that uses the serverside values of the fields.
But now the user can submit the form even if it is not correctly filled.
My idea was to add a check inside the action-Method of the submit-button, so that the method is only
processed if all fields are valid. The problem here is... how do I check if the form is valid?
Obviously a boolean attribute is required fo each field, so that when all attributes are true the form is valid.
But where do I set these attributes to true or false? First thought was the action Method of the onblur Ajax-Request of each field.
But this solution causes problems. For instance when a fields was once valid (and the serverside attribut is true) it can never become invalid
again, because if validation fails the action method is never called. so where do I set it to false again?
I had some other ideas too, but they all doesn't seem to be good.
All in all I would like to know if any of you implemented an ajax based form field validation and if so how he/she solved this.
There seems to be alot of possibilities to do it. I myself have 7 different approaches in my head (with button deactivating and additional request on onchange-events and so on). I don't want the whole thing to get to complex. Isn't there a straight solution on for this?
I hope anyone can help. Thanks alot in advance