Open AlbertoPa opened 5 years ago
Thanks for contacting us, @AlbertoPa.
We think this is a limitation with jQueryValidation
library we rely on for Client validation. If you think this can be addressed in our library, we'll happily consider a PR.
This issues seems also to affect Blazor, where jQuery is not used.
Steps to reproduce:
public double myDouble {get; set;} = 1.0e-6;
What happens The validation fails because 1.0e-6 is not recognized as a number, even if the user was correctly presented with the number if scientific notation.
Expected behavior The validation succeed if a number in scientific notation is inserted.
A note on this: using a custom validator does not resolve the issue if the type is double because the default validation is still triggered. This can be easily verified in Blazor too.
The only solution I have found at this point is to create a new input control, which seems a bit excessive for a primitive type.
Just throwing in my user voice here. My team maintains a calculation-intensive web app with hundreds of numeric inputs using InputNumber
controls bound to double
properties, and the engineers and scientists using the app expect to be able to use exponential formatting in the numeric text they enter. So for us, this is of at least medium severity. Not critical, but possibly high, and at least medium.
Data of floating point types are incorrectly forced to be numbers in general format by client-side validation, without accounting for the possibility of values displayed or inserted in scientific notation. The data-val-number tag is automatically added to, and cannot be trivially removed from the generated HTML. This causes an inconsistency because it suffices to define a default value small or big enough to be displayed in scientific notation (say, 1.0e-5) to receive a validation error at submission even if the entry is perfectly valid.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
There are two possibilities: a) values in scientific notation are accepted b) a custom validator should be able to override the data-val-number setting