By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,692 Members | 1,998 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,692 IT Pros & Developers. It's quick & easy.

want to validate a form (user and password) have default values and want to proceed

jsos20
P: 11
Expand|Select|Wrap|Line Numbers
  1.  start_form("get");   #will start the form
  2.         print "What's the User name? ",textfield(-name=>'Username',-value=>'user'),
  3.      #will get the user name
  4.  
  5.     p,  #this gives a new paragraph
  6.  
  7.     "Please enter your password: ",textfield(-name=>'password',-value=>'pass'),
  8.      #will get the password
  9.  
  10.  
  11. #to validate is the problem
  12.  
  13.  
  14.     p;
  15.         if(defined $user && $user eq "") #if the defined value is equal to/or  "blank"  print
  16.         {
  17.  
  18.         print "please enter a value for name",p;
  19.         }
  20.         else
  21.         {
  22.                 if(defined $pass && $pass eq "")  #if b's value number is blank print "please enter a value for number
  23.                 {
  24.                 print "please enter a password",p;
  25.                 }
  26.         }
  27.               print hr,
  28.  
  29.     submit('Submit Details for NextScreen');   #will submit when entered
  30.     print hr;
  31.     print hr;
  32.     sub DrawLogin {
  33.     print hr,
  34.           'Username: ',
  35.           textfield( -name=>'user', -default=>'', -size=>15 ),
  36.           p,
  37.           'Password: ',
  38.           password_field( -name=>'pass', -value=>'', -size=>15 ),
  39.           p;
  40.  
  41.     print hr,
  42.           submit( -name=>'next', -value=>'Login' ),
  43.           hr;  # submits user and pass
  44.           end_form();
  45. }
  46.  
have checked if empty but want to check if user entered data to compare against it
Apr 28 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.