Disabling jQuery Validation Error Messages

Quick tip.

There are many examples for the jQuery Validation Plugin, but I could't find one for disabling the error messages while still highlighting the corresponding fields.

After a bit of poking around I figured out the process is pretty straight forward. The jQuery Validation Plugin uses a dictionary to store the default error messages.

messages: {
	required: "This field is required.",
	remote: "Please fix this field.",
	email: "Please enter a valid email address.",
	url: "Please enter a valid URL.",
	date: "Please enter a valid date.",
	dateISO: "Please enter a valid date (ISO).",
	dateDE: "Bitte geben Sie ein gültiges Datum ein.",
	number: "Please enter a valid number.",
	numberDE: "Bitte geben Sie eine Nummer ein.",
	digits: "Please enter only digits",
	creditcard: "Please enter a valid credit card number.",
	equalTo: "Please enter the same value again.",
	accept: "Please enter a value with a valid extension.",
	maxlength: $.format("Please enter no more than {0} characters."),
	minlength: $.format("Please enter at least {0} characters."),
	rangelength: $.format("Please enter a value between {0} and {1} characters long."),
	range: $.format("Please enter a value between {0} and {1}."),
	max: $.format("Please enter a value less than or equal to {0}."),
	min: $.format("Please enter a value greater than or equal to {0}.")
}

To disable the output of an error message add the following lines of JavaScript to your page source:

$(document).ready(function() {
    // Override default error message
    jQuery.validator.messages.required = "";

    // Override generation of error label
    $("#form").validate({
        errorPlacement: function(error, element) {},
    });
}

Comments

Matt Slavin (20 Jan 2010)

Brilliant, have been looking around for this...thanks! :o)

Matt Slavin (20 Jan 2010)

Brilliant, have been looking around for this...thanks! :o)

OredgedeDpeva (21 Jan 2010)

<a href=http://comunitate.pescarul.ro/members/bvndthyturee.aspx>scary movie metacafe nude scenes</a>

Raj Gohil (04 Feb 2010)

This is great solution, Thanks

Jon (08 Feb 2010)

Thanks, this was driving me nuts today.

gaisartsmexia (26 Feb 2010)

http://gongfu.com.ua - Visit us or die! iojulmvcc

jordan shoes (12 Mar 2010)

No man or woman is worth your tears, and the one who is, won't make you cry

Add your comment

No HTML. Line breaks and URLs will automatically be converted.

(private)