Click here to Skip to main content
16,017,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

I should Validation Textbox such that after entering alphanumeric values if last value is number it should not consider a char value.

For e.g. if I enter abcd123 in textbox after 123 it should not take any char value but it must take numbers only at the end.
Posted

1 solution

You can check it on KeyPress event of Textbox, following code will allow you to enter only numbers


if (char.IsDigit(e.KeyChar))
    e.Handled = false;
 else
    e.Handled = true;


Just add some logic of counter or Flag to check if char's enter.
Once number entered set flag and allow only numeric values
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900