Reputation: 65
I have two textboxes
a date textbox
<asp:TextBox ID="txtDateofAcci" runat="server" BorderColor="#C2C4CC" BorderStyle="Solid" Height="28px" Width="135px" TextMode="Date" BackColor="#F9E3CB"></asp:TextBox>
which I have removed the spin button and set a maximum date to prevent users inputing future dates from today, however the users can still type anydate on the field
and next is a number textbox
<asp:TextBox ID="txtAffidAge" runat="server" placeholder="Your Age." type="number" min="18" max="80" value="18"></asp:TextBox>
which I have set the minimum to 18 and maximum age to 80 however the users can still type any age on the field.
How can I prevent users from putting their own input on the textbox, and force them to use only the spin button for the number field and the arrow for the calendar.
Upvotes: 2
Views: 389
Reputation: 39777
Try adding
onkeydown="return false" onpaste="return false"
to the markup of your textboxes. First will block typing in text, second - pasting it.
Upvotes: 2