SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Dublin
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question "Terms of Agreement" tick box help needed.

    Hi,

    I want to amend a form on my php based website.

    This is the form below:

    <form method="post" action="inserttemp.php" >

    <p>What is your name?
    <br /><input type="text" name="newname" id="newname" /></p>

    <p>What is your email address? <br /><input type="text" name="newemail" id="newemail" /></p>

    <p><input type="submit" name="btnSubmit" id="btnSubmit" value="Submit" class="btn"/></p>

    </form>

    I want to add a tick box where the user must accept to terms of agreement.
    If the user submits the form without ticking the box then the user is notified that “you must agree to the terms yada yada yada………..” without losing any data already inputted.

    Any help would be greatly appreciated.

  2. #2
    Also available in Large Si's Avatar
    Join Date
    Sep 2002
    Location
    Walsall, UK
    Posts
    1,911
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, JavaScript will be your friend here!

    Add a checkbox to your form with some text like so:
    Code:
      <p><input type="checkbox" name="agree" id="agree" />I agree to your terms and conditions.</p>
    You then need to add some JavaScript for when the form is submitted:
    Code:
     <form method="post" action="inserttemp.php" onsubmit="return checkForm();">
    .
    .
    .
    .
    <script language="Javascript">
    <!--
    function checkForm() {
      if(!document.getElementById('agree').checked) {
    	alert('You must agree to the terms');
    	return false;
      }
      return true;
    }
    //-->
    </script>
    Something like that should do the trick matie!
    Si
    Are you a Photoshop Jedi Master? Prove it!

    Is funky house your bag? You'll love this!

    Voice
    , eyes, ears, body and hands.


  3. #3
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Dublin
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks,

    I'll give it go!

  4. #4
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Dublin
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great that worked, thanks!

  5. #5
    Also available in Large Si's Avatar
    Join Date
    Sep 2002
    Location
    Walsall, UK
    Posts
    1,911
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Glad it worked "bird".
    Si
    Are you a Photoshop Jedi Master? Prove it!

    Is funky house your bag? You'll love this!

    Voice
    , eyes, ears, body and hands.



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •