Skip to content

Conversation

@fredgate
Copy link

When a input is of type number (instead of text) :
<input type="number" .... />
and that the user entered some letters, then jquery.validate uses false for the value of the input, and not the real string or a empty string.

This is done in the elementValue function :

elementValue: function( element ) {
  ...
  else if ( type === "number" && typeof element.validity !== "undefined" ) {
    return element.validity.badInput ? false : $element.val();
  }
  ...

In this case all the validation functions of jquery.validate.globalize working for numeric will fail as it call Globalize.parseFloat with a boolean parameter.
It is the case for the number, min, max, range functions.

In this function, instead of calling directly Globalize.parseFloat, I call a local function parseFloat that returns Globalize.parseFloat if the value is a string, otherwise an empty string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant