0

I am new to MVC 4. I have a model that has a property decorated with some range data annotation. Here is what I am trying to say.

[Range(0,11)]
[DisplayName("Height:Inch")]
public int HeightInch { get; set; }

Now here is my problem, when I try to test with single digit numbers it won't do anything until and unless I included 0 i.e. I have to make two digits to make it work. But if I test with 0 and 1 it will take it but 2 to 9 number doesn't take.

How can I format to make it work in single digit numbers?

1 Answer 1

1

If you're using the jquery-validate 1.11.0 version then this is a known issue. See this link:

https://github.com/jzaefferer/jquery-validation/issues/626

What I suggest you do is get an older version of jquery-validate or get the jquery.validate-1.11.1.js which seems to have fixed this problem.

In any case I think your problem lies in jquery-validate and you need to find the version that works as intended (we here still use 1.9.0 and Range validator works just fine).

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your reply. I got jquery.validate-1.11.1.js but still got the same problem.
I still think your problem is jquery-validate since the problem you're describing is the same issue I had before. I fixed it by going back to 1.9.0 version but I never tried 1.11.1, the only reason I mention it is because of the link I sent you says that the issue is fixed in 1.11.1. Alternatively you can try using the RegularExpression validator and trying to come up with the regular expression which will satisfy your validation condition.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.