Page 1 of 1

Accepting input into editbox...

Posted: Wed Jul 13, 2005 20:55
by Rayoom
I would like the user to only be able to enter alphanumeric characters into my editbox.

There is a function called Editbox::setValidationString(), I'm not sure exactly what this does, but perhaps it is what I am looking for?

Re: Accepting input into editbox...

Posted: Wed Jul 13, 2005 21:11
by lindquist
that function allows you to set a regular expression to be used for validating the user-entered text.

This means that you can practically do any kind of validation you wish. Given that you know regular expressions.

In your case, you can do it like this:

Code: Select all

editbox->setValidationString("[0-9a-zA-Z]*");

Re: Accepting input into editbox...

Posted: Wed Jul 13, 2005 21:16
by Rayoom
Thank you lindquist for the quick response. Since I'm not familair with regular expressions (but I can figure out what 0-9a-zA-z are ;)) what is the '*' for?

Re: Accepting input into editbox...

Posted: Wed Jul 13, 2005 21:32
by lindquist
I have a tendency to forget the details of regualar expressions very fast. But a page I usually use when in doubt is this: http://virtual.park.uga.edu/humcomp/perl/regex2a.html

the star * means that the character just to its left may be repeated any number of times (including zero).