Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: can'yt figure out whats wrong in this code?

by kcott (Archbishop)
on Nov 30, 2015 at 08:25 UTC ( [id://1148866] : note . print w/replies, xml ) Need Help??

in reply to can'yt figure out whats wrong in this code?

G'day yedukondalu,

"can'yt figure out whats wrong in this code?"

If I could run your code, I'd take a look; however, it's clear that it will die with something like

Can't open the file details.txt No such file

so there's little point in me trying.

Please provide a cutdown version, that only contains code relevant to your problem, which we can run — see "How do I post a question effectively?" for more details about this.

Also, that's a terrible title. Consider changing it to something meaningful, perhaps: "Problem validating Tk::Entry field"

"When trying to validate the age the dob validation pops without calling it's subroutine."

I can't tell what your problem is from this description. My best guess about the first part is that "-validatecommand => \&check_age" is somehow acting as if it was coded as "-validatecommand => \&validate_dob"; however, the last part is just far too vague (what's calling who's unnamed subroutine?). Please write a description which is descriptive!

As far as I can see, none of your validation routines are reading the arguments passed to them. Please see the Tk::Entry documentation; in particular, the VALIDATION section. You may also want to look at Tk::callbacks.

Your actual validation checks are also problematic. As an example:

sub check_age { if ((!$age) || ($age=~ m/[a-z]/i)) { $age_entry->messageBox( -icon => 'error',-message => 'age should +not contain characters' ,-type => 'Ok'); ...

According to this, an age of, say, "~!@#$%^&*()_+" would be perfectly OK. I don't think so!

I'd be more than happy to help you. Help me to do so.

— Ken