Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i want to make a program in which i have one textbox
i allow the specific text to insert

if set text "microsoft"
then only and only user can write microsoft

if user write 'm'
after then he/she can enter only 'i'
no other character can write..
if
after writing microsoft then textbox should be empty
and counter should be increse by 1

its a web application
then how can i solve...

help please
thanks
Posted

Create array of string.
As you type first word check with first character, if it matches go forward otherwise do not accept the string. There are text box events like 'KeyUp' where you can cancel upcoming event by doing e.cancel.

If you find exact match till end add one to counter and clear text box.
 
Share this answer
 
The easiest approach is to catch the key down / key press event by handling the events. You can then check for the key value passed and then decide if you want to display the value or cancel the event. This would normally be done via the client side script e.g. Javascript - example here[^].

Another simple approach would be to use a regular expression validator to control the input, example - How To: Use Regular Expressions to Constrain Input in ASP.NET[^]. If you can get this implemented, this would be a cleaner approach.
 
Share this answer
 
Use this Code Javascript to allow the Required String[^].

Check another condition as
if text length is equal to textbox length+1 then clear the textbox value and add the count.
 
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