I’m building an application which uses ajax calls for form validations and some others, problem is that I don’t like it when those validation errors shows up on a new page with no css at all and form completely gets reset without the javascripts.
I’m talking about a dozen forms so, it will be quite annoying for the user to go through forms over and over again.
I’ve read some answers on this topic, but is there a specific way, a best-practice for a situation like this (more along the lines of form validation)?
Apologies if there is an answer already.
Edit:
All validations are done on the server-side, currently the errors are being displayed with the help of ajax. What I’d like is a convenient method for repopulating the form and display errors without javascript if an error occurs while processing the form.
I’m not sure if you’re implying by your question that you don’t validate on the server – this would be considered a huge security hole as quite obviously forms could be bypassed by simply disabling Javascript. You have to validate in the server every time, while client-side validation is simply nice to do.
Furthermore, the “problem” of having the forms reset themselves when the page is reloaded becomes moot when you use a decent framework – In Python, Django auto-repopulates forms in the case of errors. In PHP, CakePHP and CodeIgniter do as well, and I’m sure most good frameworks do this, as it falls under the category of “common tasks” that frameworks are supposed to abstract away.
Whenever I’m not using a framework, I write up my own little Form class that fills the need.
EDIT:
I am not aware of anything you could plug-in to what you have to be able to repopulate the form. Your best bet is writing your own little class for it, which should take no more than 1 hour.