ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Data validation for double variable
Title:
B
I
{code}
?
I have create a grid with a column called `Tarif (double)`. When I edit this record, I used the following View: @Html.EditorFor(o => o.Tarif) The viewmodel for tarif is : [Required] [DataType(DataType.Currency)] public double Tarif { get; set; } In the edit form, I get the validation error "The field Tarif must be a number." if I write any number that is not an integer (for example `2.5` or `2,5`). This error does not occured when I debug the application within Visual Studio, but only when the application is published in IIS. How to solve this ?
Save Changes
Cancel
Alain Rime
asked at 25 Feb 2016
Answers
B
I
{code}
?
it tells you that it needs to be a number because it's of type `double` on your client machine and on the server you have different *regional settings* for numbers one is using comma `2,5` and the other is using dot `2.5` in our demos for client validation (jquery.validate) you can see a line in `utils.js` if (decimalSep == ',') setjQueryValidateDecimalSepComm(); this is called in `utils.init();` since you say that the textbox (or what have you in there) got cleared, my guess is that server validation didn't pass, you could look in the browser console -> network tab and see the ajax requests, and if that's true you don't see a validation message because you don't have a `@Html.ValidationMessage` for that field, or for the form (summary)
Save Changes
Cancel
Omu
answered at 25 Feb 2016
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK