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

range="13,23" doesn't work, nor does range="[13,23]" in markup #447

Closed
rikkipitt opened this issue Jun 15, 2012 · 4 comments
Closed

range="13,23" doesn't work, nor does range="[13,23]" in markup #447

rikkipitt opened this issue Jun 15, 2012 · 4 comments

Comments

@rikkipitt
Copy link

Hi guys,

When using range="[13,23]" or range="13,23" - the validation fails unless the number inputted is 1 - 3.

I think the line below is the culprit (doesn't seem to listen to the array or series of numbers correctly):

rules[this] = [Number(rules[this][0]), Number(rules[this][1])];
@giubueno
Copy link

I have just fixed my copy of the version 1.9.0 applying the solution bellow and using eval() instead of split().

The original fix
#112

The changed solution

        // Patch by Chris Tierney (CF Webtools 7/13/2011)
        // Issue logged at https://github.com/jzaefferer/jquery-validation/issues/112
        $.each(['rangelength', 'range'], function() {
            if (typeof rules[this] == 'string') {
                // giubueno: I changed it to use eval instead of split
                rules[this] = eval(rules[this]);
            }
            if (rules[this]) {
                rules[this] = [Number(rules[this][0]), Number(rules[this][1])];
            }
        });

@skarkkai
Copy link

Using eval() is a poor idea. http://christierney.com/2011/07/13/jquery-validate-range-method-patch/ gives a better fix. With it, range="13,23" works.

@giubueno
Copy link

skarkkai, I tried it but it didn't worked for me. That's why I suggested that 'poor' solution. By the way, did you noticed that I wrote this #112 ?

@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.

To the reporter (or anyone else interested in this issue): If you're affected by the same issue, consider opening a new issue, with a testpage that shows the issue. Even better, try 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!

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

4 participants