Ajax form validating

Drupal has a wonderful form processing subsystem, especially in 5.x.

Now, hook_validate only gets invoked after pressing the submit button.

But the form items which are rejected by hook_validate, such as required fields, don't provide good visual feedback to the user.

There are a lot of average users asking why the form remains the same after pressing submit.

If validation could be done via Ajax, the fields which have errors (set by form_set_error) should give better visual feedback to the user which is easily noticed.

ATM, Ajax form validating should be compatible with 5.x, which means no more API changes.

Validating input is a critical element to almost any non-trivial software application.

Regardless of the purpose of the application, its architecture, or the platform on which it will run, it is standard practice to verify that all input is valid before being accepted.

ajax form validating-28ajax form validating-62

Server-side validation is the industry standard but it requires the user to fill out the form, click Submit, and wait for a page refresh.

While the best technical solution, it provides a poor but accepted user experience.

Although client-side validation, using Java Script, provides immediate feedback and an enhanced user experience, it has many disadvantages such as being tedious and error-prone to develop, being hard to test, and leading to fragile code.

Inconsistent implementations across different browsers and the fact that a user can disable Java Script is enough to conclude that client-side validation alone is not sufficient.

Although a hybrid approach of performing validation on both the client and server may seem like a good solution on the surface it doesn't take long to realize that the increased development time, duplication of logic, and inevitable maintenance and testing problems quickly outweigh the advantages.

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “ajax form validating”