Here are a couple of ideas, first instead of making the font tag optional, just make the color optional, this will let you use a close font tag and only one compairison.
Tr (td({-align=>'right'},["<FONT ".($state==2?"COLOR=FF0000":undef).">
+First Name</FONT>"]),td({-align=>'left'},[ textfield(-name=>'user_fir
+stname' ,-default=>$userinfo[0])])),
Since you are only doing one compairison you could even call your sub from within the statement.
Tr (td({-align=>'right'},["<FONT ".(val_sub($userinfo[0])==2?"COLOR=FF
+0000":undef).">First Name</FONT>"]),td({-align=>'left'},[ textfield(-
+name=>'user_firstname' ,-default=>$userinfo[0])])),
Another variation that I like to use is to change the background color of both cells instead of the font color of one cell (users can find the errors quicker). I hope this gives you some ideas and that other people will post how they have done this.
P.S. The above code is untested (but I did look at my previous work).
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.