jQuery Form Validation

jQuery From Validation is a pugin very easy to use in witch data attributes are used to set validation rules and specific validation messages to override the default ones. Ex:

<input type="text" name="username" class="validate" data-rules="required|minlength[4]" />

Using this rule we tell the plugin that the field is required and it should have at least 4 characters in length otherwise it will be considered as invalid.

Also you can define specific messages like we did mention before doing the next:

<input type="text" name="username" class="validate" data-rules="required|minlength[4]" data-message="The username should be at least 4 characters long."/>

The plugin itself its very easy to use. It has only, for the moment, 4 configurations, two callbacks to be executed when the field is invalid or valid, and two more callbacks when the whole form is valid or not.

$('.validate').validate({
	onInvalid: function(el, msg){
		alert(msg);
	},
	onValid: function(el){
	},
	onSuccess: function(){
		alert("Success! Let's submit the form.");
	},
	onError: function(){
		alert("The form didn't passed the validation.");
	}
});

Also it has a simple language system that can be modified for everyone to alter the validation messages.

The plugin with examples can be downloaded form here: https://github.com/seinoxygen/jquery-validation

In case to find a bug or want a specific function can submit a ticket here.

You may also like...

Leave a Reply

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