SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member fungens284's Avatar
    Join Date
    Jul 2006
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    email script need javascript help

    ok i have this email script and i want to know if there is a javascript to where if they did not click the check box to agree to the terms and conditions they could not send it or press submit? could any one help me

    -thanks

  2. #2
    I ♥ PHP
    Join Date
    Jul 2003
    Location
    Melbourne, Australia
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi fungens284, the following code should help.
    Code:
    function validate()
    {
       var check = document.getElementById('chkAgree');
    
       if (check.checked == true)
       {
          return true;
       }
       else
       {
          alert('You have not agreed...');
          return false;
       }
    }
    
    <input type="checkbox" id="chkAgree" /> Agree?
    <input type="submit" onclick="validate()" />
    Now this will need to be worked in to your code, but you chould be able to see what is happening. When the user clicks the Submit button, the function "validate" is called. It checks to see if the checkbox with the id of chkAgree is checked. If so, it returns true, allowing the submit process to go ahead. If not, it pops up an alert box letting the user know they have not agreed, and returns false, cancelling the submit process.

    Regards,
    Jordan

  3. #3
    SitePoint Member fungens284's Avatar
    Join Date
    Jul 2006
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok thanks it worked great!

  4. #4
    I ♥ PHP
    Join Date
    Jul 2003
    Location
    Melbourne, Australia
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are welcome.

    Regards,
    Jordan


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
  •