may i know the snippet for disabling any number input, letter input or character input in asp.net?
hmm, what i want is when a user presses a key, if it's not needed, the key typed shouldn't show. hmm, for example, i want to input numbers only, special characters and letters shouldn't be enabled when i press them. same goes for the other types of input..
2 replies to this topic
#1
Posted 07 February 2011 - 01:34 PM
|
|
|
#2
Posted 09 February 2011 - 05:58 AM
I'm assuming you're talking about input for a TextBox. If you want to do this on the client then you will most likely need to write a javascript function that doesn't allow certain things to be typed. Otherwise, you can use a RegEx (Regular Expression) validator on the textbox and when the form is submitted, if it doesn't meet the RexEx requirements it will give an error and ask the user to change the value. If you use the RegEx Validator and don't want the user to see the postback you should put the form in an update panel.
Let me know if you have any other questions. :)
Let me know if you have any other questions. :)
-CDG10620
Software Developer
Software Developer
#3
Posted 13 February 2011 - 09:01 PM
Regular Expression Controls in Validation Tab of visual Studio are used for this purpose drop the code in html view and try it by changing the control to validate property
<asp:RegularExpressionValidator ID="rgvFirstName" runat="server" ControlToValidate="first name textbox ID"
Display="Dynamic" SetFocusOnError="True" ValidationExpression="^[a-zA-z0-9 ]{10,20}$"
Text="Hello you typed wrong" ErrorMessage="Hello">
it accepts a-z, A-Z , 0 -9 upto 20 characters should be minimum of 10 characters
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









