Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi!

 

I am trying to create a textbox that will only allow certain characters (such as "A" or "V").

For example:

 

-If the user typed in the string "AVVA", then the code would evaluate as true

 

-However if the user added another character "AVVAM" then it would evaluate false.

 

How could this be accomplished?

Posted
regex would validate character strings for you. vs magazine had an article implementing this kind of thing a few months ago. do a search on their site and it will provide all the info you need.
Posted
If the values weren't many you could also just check it on key press and if it wasn't an allowed key then you would cancel the key press. Sometimes regex can be overkill if it's something simple; especially if you don't know regex.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...