I've got a problem with validation of numbers using jquery unobtrusive validation. The versions I'm using are: ASP.MVC 3. JQuery 1.9.1 JQuery UI 1.10.1 JQuery Validation 1.11.0
the input I'm trying to validate is :
<input type="number" value="0" name="Data.time_between_loops.Planned.hour" id="Data_time_between_loops_Planned_hour" data-val-required="The hour field is required." data-val-range-min="0" data-val-range-max="23" data-val-range="The field hour must be between 0 and 23." data-val-number="The field hour must be a number." data-val="true" class="hour valid">
The validation is performed, but the problem is that it is performed on the value AS a string, i.e. when I type 4 I get a validation error.
I looked at the code of jquery.validation and it looks like it does not convert the any of the values (element value,min/max) to a number, and so the range function compares the values are strings. I assume that if you set the min/max range in jquery then the values will not be strings, but when you specify them in data attributes they ARE strings and jquery does not seem to handle this.
Is this ready a bug in jquery validation or am I doing something wrong?
Thanks, Nadav How do I fix this problem?