Menu

Making Fields Optional/Required

Help
Pewit
2006-03-04
2013-06-03
  • Pewit

    Pewit - 2006-03-04

    I have spent a long time customising a form and adding new fields and I don't want to have to repeat the proecss of generating it again but I do want to be able to turn the Required flag off on a field.

    I am aware of the fact that this will require changes to the process.php field and possibly to the  MySQL table. I can see the error message generation in the process.php file but I can't see where the flag is set which defines Required or Optional fields  - it must be when form1 is displayed otherwise the fields would not change state to have a yellow background.

    It would be helpful if there was some more documentation or code comments which gave information about the relationship between the various form files generated and the database table.

    Regards

    Paul

     
    • TNTEverett

      TNTEverett - 2006-03-12

      Required fields in the form can be marked by any method (coloered text or backgrounds, asterisks, etc..) to que the form user to enter specific data.  The real meat of the method is in the process.php file.  This file can check blank as well as incorrect syntax for form entries.  If you wish to turn the option on and off you must change the form so that users don't think the entry is required, then you need to change the process.php file to make sure the entry is not checked. 
      These lines do the checking in most process.php files:
      if($FirstName=="" || $LastName=="" || $Email=="" ){
      $errors=1;
      $error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
      }
      If I did not want to make the FirstName a required field I would remove "$FirstName=="" || " from teh if statement. 
      Let me know if you still need help.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.