Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not call Globalize.parseFloat if the value is not a string. #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

None yet

1 participant