Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jul 2007
    Location
    UK
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Registering help?

    Hi, on my website when you register you have to tick the boxs to say that you are over 13 and you agree to the terms of service, how would i make it so you cannot register until you have tick the 2 boxes.

    I have this:


    Code:
    <script language=JavaScript>

    function over13check(a)
    {if (a.over_13.checked == false )
    {alert('You must be over 13 to register on SMGames.');
    return false;}
    else
    return true;}

    function toscheck(t)
    {if (t.tos.checked == false )
    {alert('You must accept the Terms of Service in order to register.');
    return false;}
    else
    return true;}
    </script>
    But its not working, what else would i need.


    Also i need help with another thing, there are 2 password boxes, one for your password and one for confirm password, how would i make it so they have to match, does it have something to do with variables? can anyone help me?
    http://www.smgames.staticfire.co.uk Under construction, Currently hiring mods and admins anyone interested pm me.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,919
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Try this:-

    <form name = "a">
    <input type = "checkbox" name = "over_13" >
    <input type = "checkbox" name = "tos" >
    <input type = "button" name = "button1" value = "Click Me" onclick= "over13check()">

    <script type = "text/javascript">

    function over13check() {
    if (a.over_13.checked == false) {
    alert('You must be over 13 to register on SMGames.');
    return false;
    }
    if (a.tos.checked == false) {
    alert('You must accept the Terms of Service in order to register.');
    return false;
    }
    else
    return true;
    }

    </script>

    </form>


    Your supplementary question:-


    <form name = "b">

    <input type = "text" name = "password1">
    <input type = "text" name = "password2" onblur = "checkpwd()">

    <script type = "text/javascript">

    function checkpwd() {
    if (b.password1 != b.password2) {
    alert ("Passwords must match!");
    b.password1.value = "";
    b.password2.value = "";
    b.password1.focus();
    return false;
    }
    else {return true}
    }
    </script>

    </form>

    Naturally all this could be contained within one form.
    Last edited by Philip M; 07-06-2007 at 05:25 PM. Reason: Typo

  • #3
    New Coder
    Join Date
    Jul 2007
    Location
    UK
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hmm well this is my registering code
    Code:
    <form method="post" action="insert.php">
    
    
    
    
    <table width="525" height="540" cellpadding="10" cellspacing="0" border="0" background="images/sidebar_back.png">
    <tr>
    <td align="left">
    <center>
    <table width="450" cellpadding="3" cellspacing="0" border="0" bgcolor="#FFFFFF">
    <tr>
    <td align="right"><font color="#007fff">*</font> User Name</td>
    <td align="left"><input type="text" name="loginname" maxlength="18"></td>
    </tr>
    <tr>
    <td align="right"><font color="#007fff">*</font> Password</td>
    <td align="left"><input name="password" type="password"></td>
    </tr>
    <tr>
    <td align="right"><font color="#007fff">*</font> Verify Password</td>
    <td align="left"><input name="password1" type="password"></td>
    </tr>
    <tr>
    <td align="right"><font color="#007fff">*</font> Email</td>
    <td align="left"><input type="text" name="email"></td>
    </tr>
    <tr>
    <td align="right"><font color="#007fff">*</font> I am 13 or older</td>
    <td align="left"><input type="checkbox" name="over_13" value="1"></td>
    </tr>
    <tr>
    <td align="right"><font color="#007fff">*</font> I agree to the <a href="terms.php"> ToS</a></td>
    <td align="left"><input type="checkbox" name="tos" value="1" />
    </td>
    </tr>
    <tr>
    <td align="right"></td>
    <td align="left"></td>
    </tr>
    <tr>
    <td align="right">Real Name</td>
    <td align="left"><input type="text" name="name"></td>
    </tr>
    <tr>
    <td align="right">Age</td>
    <td align="left"><input type="text" name="age" maxlength="2" size="2"></td>
    </tr>
    <tr>
    <td align="right">Gender</td>
    <td align="left"><select name="gender">
    <option value="0" selected="selected"></option>
    <option value="1">Male</option>
    <option value="2">Female</option>
    </select></td>
    </tr>
    <tr>
    <td align="right">Location</td>
    <td align="left"><input type="text" name="location"></td>
    </tr>
    <tr>
    <td align="right" valign="top">Description</td>
    <td align="left"><textarea cols="35" name="description" rows="4"></textarea></td>
    </tr>
    <tr>
    <td align="right"></td>
    <td align="left"><font color="#007fff">*</font>required fields.</td>
    </tr>
    </table>
    <table width="450" cellpadding="3" cellspacing="0" border="0" bgcolor="#FFFFFF">
    <tr>
    <td align="right">
    
    <input type="submit" value="Register">
    
    </td>
    </tr>
    </table>
    </center>
    </td>
    </tr>
    </table>
    </form>
    Which looks like http://www.smgames.staticfire.co.uk/register.php

    I have tried and tried to put it into my code buts its confusing could you help me putting it in.
    http://www.smgames.staticfire.co.uk Under construction, Currently hiring mods and admins anyone interested pm me.

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,919
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Make your submit button so:-

    <input type="submit" name = "submitbutton" value="Register">

    and then:-

    <form method="post" action="insert.php" onsubmit="return over13check(this.submitbutton)">

    This calls the script over13check() which I gave you, and returns true or false.

    As far as the password check is concerned:-

    <td align="right"><font color="#007fff">*</font> Verify Password</td>
    <td align="left"><input name="password1" type="password" onblur=checkpwd()></td>

    For some reason you have named the form fields "password" and "password1" when in the script I named them "password1" and "password2". I guess you realise that these egregious changes will prevent the script from running.

    Just as a detail, I prefer to make the 'password' and 'confirm password' boxes type = "text", not type = "password" at the initial registration stage, so that the user can see what he has typed. Then of course type = "password" for subsequent logins.
    Last edited by Philip M; 07-07-2007 at 01:47 PM.

  • #5
    New Coder
    Join Date
    Jul 2007
    Location
    UK
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmm about changing the password to text, the confirm password is so you no what the passwords are, but ok, thanks
    http://www.smgames.staticfire.co.uk Under construction, Currently hiring mods and admins anyone interested pm me.


  •  

    Posting Permissions

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