jQuery Validation Plugin – How To Show Custom Error Messages

Author: Zeeshan Rasool  |  Apr 27, 2015 JQuery

Every developer uses validations for HTML forms and its better to use a plugins instead of custom validations because this way we will not only save our time, but also we will have some efficient & bugs free script. jQuery Validation plugin is a a best and simple validation plugin which you can use for your projects. In this post I will show you how we can use custom error messages instead of default error messages sent from plugin.

Below HTML code shows a form with 3 fields first name, last name & email address.

In errorPlacement function, we will embed the custom error messages where ever we will want to show them on the form. The following function is showing the text error messages as placeholder inside the text field.

We can highlight the input field on errors and we have highlight: function (), in which we will add a class to the input field with error.

We have defined a css class which we will append to the input field if there is any validation error. It will turns the background color of field into red.

Output:

form-1

Recommended WordPress Themes Stores



If you enjoyed this post, please consider leaving a comment below or subscribing to the RSS feed to have future articles delivered to your feed reader. You can also follow us on Facebook or Twitter @99Points

This awesome post has been created by 99Points editor's team. You can follow our updates on Twitter and facebook, OR drop an email at 99points.info@gmail.com



Email Subscriber!

Be the first to know about new updates


Author of 99Points
Zeeshan Rasool is an experienced PHP Web Developer and founder at 99Points. Expert in Codeigniter (MVC), WordPress, JSON, jQuery & HTML5
 LinkedIn Profile  About.me


Advertisement




Friends


Categories


Popular post