Very Simple jQuery Validation with custom error message!


If you are a web developer you should be doing form validation for almost all of your websites, spending time on validation is another issue if you are working in a company, everybody in this programming world is in hurry, they need all the functionality should be done in 1 or 2 days.

To overcome this issue you are going to need a jQuery validation plugin where you can download and use it on any of your project.

Even I struggled a lot of time doing this Form validation and then decided to write a plugin. After writing this I’m not spending much time doing form validation. Actually saying this script will take mostly 5-10 minutes of your time to integrate this in your project.

Here is the demo and download link:

demo download

What does this jQuery Validation script do?

1. Checks if all the input fields are entered.
2. Validates the email addresses.
3. Finds if the checkbox or radio button is checked.

How to use this validation script?

Only two information you have to provide for this script:

1. Form ID
2. All mandatory field IDs

Open the simpleValidation.js and give the below details and that’s enough:

var formid = "myform";
var requiredfields = 	{	"yourid" : "custom error msg", 
				"email": "Please enter your email",
				"message" : "Please fill the message box",
				"agreebox": "Please check the checkbox"

And there is a class used in this jQuery Validation script. which is ‘requiredfield‘. You may need to style this according to your needs.

for example (this you need to add it in your CSS):

  color: red;

All you need to do is only the above steps, that’s all, the script will do the other stuffs.

If you want to edit the script, you can do that as you wish. All the information how the script works everything is written in the JavaScript itself.

Enjoy the day!

2 thoughts on “Very Simple jQuery Validation with custom error message!

Leave a Reply

Theme: Overlay by Kaira