mirror of
https://github.com/jquery-validation/jquery-validation.git
synced 2025-12-14 20:35:47 +01:00
Core: Update elementValue method to deal with type="number" fields
The HTML5 draft defines, for type="number" inputs: "The value sanitization algorithm is as follows: If the value of the element is not a valid floating-point number, then set it to the empty string instead." If the constraint validation considers the input invalid, return false as the value, instead of the empty string, for the number and digit methods to output their messages. This would break in browsers that support type="number", but not the constraint validation API. I don't know of any existing browser where that applies. Fixes #858 Fixes #922 Closes #1093
This commit is contained in:
committed by
Jörn Zaefferer
parent
104e8efceb
commit
d09a5ee199
@@ -554,6 +554,8 @@ $.extend($.validator, {
|
||||
|
||||
if ( type === "radio" || type === "checkbox" ) {
|
||||
return $("input[name='" + element.name + "']:checked").val();
|
||||
} else if ( type === "number" && typeof element.validity !== "undefined" ) {
|
||||
return element.validity.badInput ? false : $(element).val();
|
||||
}
|
||||
|
||||
val = $element.val();
|
||||
|
||||
Reference in New Issue
Block a user