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

Min and max validation now use type attribute to determine behavior #355

Merged
merged 1 commit into from
Oct 31, 2013

Conversation

codethug
Copy link
Contributor

When used as HTML5 attributes, min and max were comparing as strings. So an element of <input min="10" data-bind="value:myNumber"> would validate successfully for a value of 5, because the string "5" is greater than the string "10". This was understandably causing some problems.

This update changes the min and max validators so that they pay attention to the type attribute. For example, the element <input type="month" min="2010-03" data-bind="value:myMonth"> will use appropriate logic to ensure that the entered date is entered as a month and is March 2010 or later. And an element of <input type="number" min="10" data-bind="value:myNumber"> will fail validation if a value of 5 is entered.

Tests and Documentation updates included.

This was originally in PR #324, but I decided to create a new PR after the Knockout-Validation folder restructuring so that this could be a single, clean commit.

Thanks to @stevegreatrex for help in reviewing this feature.

stevegreatrex added a commit that referenced this pull request Oct 31, 2013
Min and max validation now use type attribute to determine behavior
@stevegreatrex stevegreatrex merged commit f9d4eb4 into Knockout-Contrib:master Oct 31, 2013
@codethug codethug deleted the minmax2 branch February 24, 2014 21:02
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

2 participants