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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jsos20
    New Member
    • Mar 2010
    • 11

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

    Code:
     start_form("get");   #will start the form
            print "What's the User name? ",textfield(-name=>'Username',-value=>'user'),
         #will get the user name
    
        p,  #this gives a new paragraph
    
        "Please enter your password: ",textfield(-name=>'password',-value=>'pass'),
         #will get the password
        
    
    #to validate is the problem
    
    
        p;
            if(defined $user && $user eq "") #if the defined value is equal to/or  "blank"  print
            {
    
            print "please enter a value for name",p;
            }
            else
            {
                    if(defined $pass && $pass eq "")  #if b's value number is blank print "please enter a value for number
                    {
                    print "please enter a password",p;
                    }
            }
                  print hr,
    
        submit('Submit Details for NextScreen');   #will submit when entered
        print hr;
        print hr;
        sub DrawLogin {
        print hr,
              'Username: ',
              textfield( -name=>'user', -default=>'', -size=>15 ),
              p,
              'Password: ',
              password_field( -name=>'pass', -value=>'', -size=>15 ),
              p;
    
        print hr,
              submit( -name=>'next', -value=>'Login' ),
              hr;  # submits user and pass
              end_form();
    }
    have checked if empty but want to check if user entered data to compare against it
Working...