I have an annotated data model that looks something like this:
Public Class Task
Public Property TaskID As Integer
<Range(0, 999999999, ErrorMessage:="Please enter a valid number.")>
Public Property EstimatedHours As Nullable(Of Decimal)
End Class
This correctly validates the Estimated Hours
field, and displays the error message if a user enters anything that is not between the specified range. My issue with this, however, is that it is PASSIVE validation. It allows users to enter "asdasfs2312" and then hit submit.
What I would like is ACTIVE validation, i.e. an input field that completely prevents a user from entering letters at all. Is there a simple way to do this within ASP.NET? I haven't had any luck yet with HTML5 number input types nor jQuery UI spinners.
So far the only solution I've found is pretty hacky.
EDIT : Just to clarify, I have both client and server side validation. I am just looking for a way to actively prevent client side input in a restrict-as-you-input fashion to cut down on the time it takes for a user to submit the form and THEN receive an error message.