One of the most common tasks of a (web) developer is to implement validation for forms using latest technologies like jQuery. Validation needed almost for every form on every website or a blog mostly on wordpress as you simply cannot trust user input these days, who can throw millions of spam messages to crash your website. When it comes to simpler user experience, having your form validation happen instantly on the same page is a lot cleaner than reloading pages and possibly losing some form content. In this article we have showcased useful 10 Tips Adding Form Validation to WordPress Comments Using jQuery to do some instant checking on an example comment form.
For our example we’re going to add form validation to a comment form in the default WordPress theme. The process is much the same for any type of form validation however so you could easily apply this technique to a non-WordPress example.
The theme we will add the validation to is WordPress’ Default theme that comes packaged with every install. So if you’d like to follow along completely, just head to WordPress.org and download and install a copy on your server.
With validation, users can submit their comment and instantly see if they’ve hit an issue. There is no need to submit the page and get WordPress’ default “There is a problem…” page. Instead, errors are displayed inline instantly.
In this tutorial, i am going to show how easy to validate a form with jquery. For this you will need to download the following:
I will focus mostly on front-end validation and dive into back-end validation where needed. Much of this article can be used for any back-end, including PHP, J2EE, .NET and Lotus Notes.