Improve error handling when no element is missing its name attribute. Still need to set debug flag to see exception.

This commit is contained in:
Jörn Zaefferer
2013-01-31 00:44:34 +01:00
parent fddd3b70dc
commit 22edeaf28f

7
jquery.validate.js vendored
View File

@@ -471,8 +471,11 @@ $.extend($.validator, {
.not(":submit, :reset, :image, [disabled]")
.not( this.settings.ignore )
.filter(function() {
if ( !this.name && validator.settings.debug && window.console ) {
console.error( "%o has no name assigned", this);
if ( !this.name ) {
if ( window.console ) {
console.error( "%o has no name assigned", this );
}
throw new Error( "Failed to validate, found an element with no name assigned. See console for element reference." );
}
// select only the first element for each name, and only those with rules specified