SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    My precious!!! astericks's Avatar
    Join Date
    Mar 2002
    Location
    Vancouver, BC
    Posts
    1,971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Popup upon not checking checkbox

    i have a checkbox and a submit button, i need some code that will popup a window saying you have to select the check box before u can submit [if checkbox is not selected upon pressing of 'send' button]

    i searched a few JS sites already, with no luck. And i'm no whiz at it. Can any of you help me out here?
    Any help will be appreciated

    asT.

  2. #2
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    420
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Put this before your button somewhere:

    Code:
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function checkthebox() {
      if (document.form1.checkbox.checked == false){
      alert('You Forgot To Click \" I agree \"');
      }
    }
    -->
    </script>
    Then heres the form code:

    Code:
    <form name="form1" method="post" action="">
      <p> 
        <input type="checkbox" name="checkbox" value="checkbox">
        I agree </p>
      <p>
        <input type="submit" name="Button" value="Next" onclick="checkthebox()">
      </p>
    </form>
    I think that should do it. If you need help feel free to pm me.
    Wavelan

  3. #3
    My precious!!! astericks's Avatar
    Join Date
    Mar 2002
    Location
    Vancouver, BC
    Posts
    1,971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks bro.

  4. #4
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you would prefer this one. As the one above will send itself any way. Instead this will not send unless it is ticked

    PHP Code:
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function 
    checkthebox()
    {
      if (
    document.form1.checkbox.checked == true)
        {
         
    document.form1.submit();
      }
        else
        {
         
    alert('You Forgot To Click \" I agree \"');
        }
    }
    -->
    </script>

    <form name="form1" method="post" action="gffgj">
      <p> 
        <input type="checkbox" name="checkbox" value="checkbox">
        I agree </p>
      <p>
        <input type="button" name="Button" value="Next" onclick="checkthebox()">
      </p>
    </form> 


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
  •