Lakhae
Lakhae

Reputation: 1899

How to custom number formatting in ASP.Net MVC4

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?

Upvotes: 0

Views: 144

Answers (1)

Marko
Marko

Reputation: 13263

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

Upvotes: 1

Related Questions