Would you please help me on this subject that has driven me crazy. My goal is to make sure the users always enter the word "go " before anything else to be entered in my Entry. For example, "go east" or "go west" is OK. At first, I thought I could do:
-validatecommand => ( $_1 =~ /^go / ) ;
But it won't work. It looks like -validatecommand doesnot like to match the whole word of "go".
Is there any way in Perl Tk that allows us to validate string that the users enter in Entry box?
For your reference, my simple code is below:
Thanks very much for your help,require Tk; use Tk; $mw = MainWindow->new(); $mw->Entry( -textvariable => \$content , -validate => 'key' , -validatecommand => ( $_[1] =~ /^go / ), -invalidcommand => sub { print "ERROR.\n", $mw->bell() } ) +->pack() ; MainLoop;
In reply to how to use validatecommand for string checking by dannytrannox
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |