Core: Required rule take precedence over number & digits rules

Ref #1611
Ref #1663
Fixes #1514
This commit is contained in:
Brahim Arkni
2016-01-07 23:09:41 +00:00
committed by Markus Staab
parent df0f27321f
commit 40dae365ed
2 changed files with 44 additions and 2 deletions

View File

@@ -644,7 +644,7 @@ $.extend( $.validator, {
if ( type === "radio" || type === "checkbox" ) {
return this.findByName( element.name ).filter( ":checked" ).val();
} else if ( type === "number" && typeof element.validity !== "undefined" ) {
return element.validity.badInput ? false : $element.val();
return element.validity.badInput ? "NaN" : $element.val();
}
if ( element.hasAttribute( "contenteditable" ) ) {
@@ -713,7 +713,6 @@ $.extend( $.validator, {
for ( method in rules ) {
rule = { method: method, parameters: rules[ method ] };
try {
result = $.validator.methods[ method ].call( this, val, element, rule.parameters );
// If a method indicates that the field is optional and therefore valid,