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

Max value dont work with zero decimal places #1191

Closed
danielhusar opened this issue Jun 26, 2014 · 7 comments
Closed

Max value dont work with zero decimal places #1191

danielhusar opened this issue Jun 26, 2014 · 7 comments

Comments

@danielhusar
Copy link

Hi,

if you put inline max value like this: 1000.00 it doesn't work, however 1000.01 works fine.

Demo: http://jsfiddle.net/F2a36/

@Vyeche
Copy link

Vyeche commented Sep 19, 2014

I have a similar issue, when I pass a value like "42.0000" I get it flagged as an error. If I pass that number as a number and not a string. It works fine. My work around was to wrap Number method around value to parse the odd string:

    // http://jqueryvalidation.org/max-method/
    max: function( value, element, param ) {
        return this.optional(element) || Number(value) <= param;
    },

I'm not sure why this needs to be done in my case... Something odd is going on with my 'value' property.

This code piece is found on line 1221 in the jquery.validate.js file. Using jQuery Validation Plugin v1.13.0.
I have some code that adds up total of numbers and converts it by using Number(a + b + c). Then I pass that over as the new value to be checked.

@danielhusar
Copy link
Author

Hi @Vyeche yeah thats true.

In your case I think rather than altering original plugin you should just overwrite that method in separate file so you can still get updates to main plugin.

@Vyeche
Copy link

Vyeche commented Sep 22, 2014

@danielhusar Good point. Quick question, is this an issue in the plugin? I'm pretty sure that I'm overlooking something?

I tried extending it this way, I'm assuming this is okay?

        $.validator.methods.max = function (value, element, param) {
            var v = value.replace(/,/g, '');
            return this.optional(element) || Number(v) <= param;
        }

        $.validator.methods.min = function (value, element, param) {
            var v = value.replace(/,/g, '');
            return this.optional(element) || Number(v) >= param;
        }

@jzaefferer
Copy link
Collaborator

I'm sorry for the lack of activity on this issue. Instead of leaving it open any longer, I decided to close old issues without trying to address them, to longer give the false impression that it will get addressed eventually, especially after several years with no activity. It doesn't mean I'm abandoning the project, just that I'm unable to work through 200+ open issues with the little time I can afford to spend on this project.

To the reporter (or anyone else interested in this issue): If you're still affected by the same issue, please consider opening a new issue, with a testpage that demonstrates the issue with a current version of the plugin. Even better, make an attempt to fix the issue yourself, and improve the project by sending a pull request. This may seem daunting at first, but you'll likely learn some useful skills that you can apply elsewhere as well. And you can help keep this project alive. We've documented how to do these things, too. A patch is worth a thousand issues!

@danielhusar
Copy link
Author

Hey,

That's fair enough. :)
But I think closing the issue might be misleading for some people, you should rather tag it help wanted

@jzaefferer
Copy link
Collaborator

#1391 should solve this.

@jzaefferer
Copy link
Collaborator

@danielhusar its now fixed :-)

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

No branches or pull requests

3 participants