Menu

required checkbox to accept t&c's

Help
Dezb
2012-03-13
2013-06-03
  • Dezb

    Dezb - 2012-03-13

    Hi Folks

    I need to have a check box that requires a user to accept some t&c's.  I have set it up as a required field but when the confirmation email arrives it does not contain the acceptance and also the form can be submitted without having to tick the box.

    Any ideas as to how I can sort this out please?

    Many thanks

    Dezb

     
  • TNTEverett

    TNTEverett - 2012-03-14

    It is always helpful to identify the version of the generator you are using.

     
  • TNTEverett

    TNTEverett - 2012-03-14

    There are a few posts related to this topic.  I will repeat it here for your benefit.
    Checkbox validation and "required" features were not fully developed at teh time of the most current release.  Some code will need to be added to your form HTML file in order for this to work.  This is technically only a partial solution becuase if the user's browser does not execute the javascript for any reason (not common but possible) the form will still be submitted.  In these cases you must add some additional code to the processor.php file to validate "required" fields before submitting final results.  Start with the code changes below and post again if you still need help.

    First:
    At the bottom of your HTML you will find a page validation function.  Find and identify the validation for your checkbox and change the line from
    if (validateField('field_100','fieldBox_100','checkbox',1) == false)
    to
    if (validateCheckBox('field_100','fieldBox_100','checkbox',1) == false)

    Second:
    Near the top of your HTML you will find the "validateField" function.  Right above this function you will need to add the function below.

          function validateCheckBox(fieldId, fieldBoxId, fieldType, required)
          {
            if(fieldType == 'checkbox') {
            fieldBox = document.getElementById(fieldBoxId);
            if(required == 1) {

             myfieldId = fieldId+"_option_1";
             fieldObj = document.getElementById(myfieldId);
              if(fieldObj.checked == 1)
              {

                  myfieldId = fieldId+"_option_1";
                  fieldObj = document.getElementById(myfieldId);
                  fieldObj.setAttribute("class","mainForm");
                  fieldObj.setAttribute("className","mainForm");

                return true;
              } else {
                fieldObj.setAttribute("class","mainFormError");
                fieldObj.setAttribute("className","mainFormError");
              }

            fieldObj.focus();
            return false;
           }
           }
          }

     
  • Dezb

    Dezb - 2012-03-14

    Hi tnteveret1

    My apologies, I should have said it is version 3.0.

    This works fantastically, your help is much appreciated, thank you.

    Do you have any idea when the final version is going to be ready?

    Many thanks again

    DezB

     
  • Dezb

    Dezb - 2012-03-14

    Sorry I forgot to ask, what can I add to the processor.php to get it to confirm that the checkbox has been ticked?

    At the moment it says "Agree to terms: $field_44_opts"  but I would like it to add the word "Yes" at the end of this if possible

    Many thanks

    Dezb

     
  • TNTEverett

    TNTEverett - 2012-03-15

    Without seeing both your html and processor I cannot provide exact recommendations but here is a really good tutorial on checkboxes.
    http://www.html-form-guide.com/php-form/php-form-checkbox.html
    If you still need help send me an email with the form.html and processor.php files..

     
  • Dezb

    Dezb - 2012-03-15

    Hi tnteveret1

    That's really useful, thank you.

    I have to admit I'm not a programmer , just someone who knows enough to be dangerous and likes tinkering.

    I've even managed to get two forms working on one site…

    Do you have any idea when the final version will be released and do you want any help marketing it in the UK?

    Thanks again

    DezB

     
  • Dezb

    Dezb - 2012-03-21

    Hi tnteveret1

    Is it possible to format the text that is delivered by email through the processor.php so that when it arrives in my inbox it can be easily printed out for safekeeping?

    I tried to put all fields into a table to see if that would work but when I tried to test the form it returned a syntax error.

    Hope you can help.

    Best wishes

    DezB

     
  • TNTEverett

    TNTEverett - 2012-03-22

    Of course it is possible.  Anything is possible. 
    In text emails you to insert tabs, spaces, and carriage returns in all the right places. 
    If you want to send HTML it is more involved. 

    Here are some quick tips:
    http://www.codingforums.com/showthread.php?t=142893
    Example 4
    http://php.net/manual/en/function.mail.php 

     
  • Dezb

    Dezb - 2012-03-22

    Hi tnteveret1

    Many thanks, I shall take a good look at that.

    In the meantime is is possible to create a tell a friend form with Captcha using phpformgenerator 3.0?

    Sorry to keep asking you all these questions.

    Speak soon

    dezb

     
  • TNTEverett

    TNTEverett - 2012-03-22

    Of course it is possible.  Anything is possible.
    phpFormGenerator is a simple form generator that gives you the starting point for any kind of form.  Because there are literally unlimited conbinations of form types it is impossible to cover them all in something like phpFormGenerator.  Have you seen teh commercials for "General Car Insurance"?  In this case it is "Go to the Generator and save some time".
    Generate your basic form with as many features as you need and are available.  Take that basic framework and add or modify until you have exactly what you need. 
    In your case you need an email entry box with some text that indicates you are sending a message or link to the email identified in the email entry.  Then you need Captcha security so people can not use it as a SPAM portal. 
    Go to the generator and enter form number 266190 to see an example base form with just the fields you would need to start with.  Of course modifications need to be made in order for it to work as you want it to but at least you have a head start. 

     
  • Dezb

    Dezb - 2012-03-22

    Hi tnteveret1

    I've just been looking at the sites you sent over, whoa……..

    As I mentioned before I'm not a programmer but I'm going to have a go just to see if I can make it send out an email in an html format.  That way I should be able to create a table that has fixed cell sizes to allow the email to be printed out.

    I'll let you know how I get on in a couple of months!!!…..

    I am also going to have a go at a tell a friend form but have no idea how to make it send a message to each recipient etc, wish me luck…

    Thanks again

    Dezb

     

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.