#!/usr/bin/perl -- use strict; use warnings; use Tk; my $mw = tkinit; my $name = $mw->Entry( -validatecommand => \&nodigits, -validate => 'key',)->pack; $name->focus; #~ $mw->WidgetDump; use Tk::WidgetDump; $mw->MainLoop; sub nodigits { my( $newstring, $difference, $oldstring, $index, $insertOrDelete ) = @_; my $entry = $Tk::event->W; if( $newstring =~ m/\d/ ){ $entry->bell; $entry->configure( -bg => 'red' ); $entry->after( 300, sub { $entry->configure( -bg => 'white' ) } ); return undef; } else { $entry->configure( -bg => 'white' ); return 1; } }