Adding a checkbox validation to the signup page

Discussion in 'Templates customization' started by Mandy, Jul 22, 2004.

  1. Mandy

    Mandy Guest

    Hi there

    I'd like to be able to add a checkbox validation within the form on my signup page - for a user agreement - so the form won't submit unless the checkbox has been checked.

    I know there is an option in the aMember Pro control panel for the client to be directed to the membership agreement after signup, before payment, but I don't like the look of it, my members have also told me they think it looks tacky :( and it slows the process down.

    Some of the checkbox validation scripts I have found, and tried, require a redirect link to the payment page but the aMember Pro signup page requires "signup.php#e" to pass the information onto the payment area and of course to complete the membership.

    Does anyone know of a java script that I can use to validate checkboxes that doesn't include a redirect page and that won't allow the form to be submitted unless the checkbox has been checked.

    Kind regards
    Mandy
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    You can edit signup.html template and add a checkbox field like

    <input type=checkbox name=i_agree value=1>

    and enable license requirement in product settings.
  3. Mandy

    Mandy Guest

    checkbox validation

    Thanks Alex

    I will get onto it asap. As always you saved the day! :)

    Kind regards
    Mandy
  4. will

    will Guest

    OK...I tried this, but amember doesn't recognize the checkbox or validate that it is checked before proceeding with signup. I'd like to use the checkbox for the Agreement instead of loading the Agreement on a page of its own. I thought I saw this in the forum before, but I can't find it now...
  5. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Please show me your signup page (provide URL).
  6. will

    will Guest

    Unfortunately the site is protected until it launches, and I'm under a non-disclosure agreement, so I can't disclose it.

    However, here's the code I have on the signup.html template page, edited for anything 'secret' to be removed. Not that it should matter, but I implemented the hack you suggested for making the email address the username/login for the site.

    Code:
    {assign var="title" value="Sign-up"}
    {include file="header.html"}
    <div id="welcome"><h1>Join Us</h1></div>
    <a name="e">&nbsp;</a>
    {if $error}
    <p>Please fix the following error(s):</p>
    <ul>{foreach from=$error item=e}
    <li class="error">{$e}</li>
    {/foreach}
    </ul>
    {/if}
    <div id="amember">
    <form name="signup" method="post" action="../../members/signup.php#e">
    <fieldset>
    <legend>Membership Type</legend>
    {* If products count > 1, then build select, else just display one title *}
    {if count($products)>1}
        <table width="100%">    {foreach from=$products item=p} 
    		<tr>
    		<td><input type="radio" id="product{$p.product_id}" name="product_id" value="{$p.product_id|escape}"
            {if $p.product_id == $smarty.request.product_id }checked{/if} /></td>
    		<td><label for="product{$p.product_id}"><b>{$p.title} ({if $p.price > 0 }{$config.currency|default:"$"}{$p.price}{else}free{/if})</b><br />
            <small>{$p.description}</small></label></td>
    		</tr>
        {/foreach} </table>
        
    {else} {* If only one membership type enabled *}
    
    <p><strong>Membership Type</strong></p>
            {foreach from=$products item=p} 
            <p><label for="product_id">{$p.title}</label></p>
    		<p>({if $p.price > 0 }{$config.currency|default:"$"}{$p.price}{else}free{/if}) - {$p.description}</p>
            <input type="hidden" name="product_id" id="product_id" value="{$p.product_id}" />
            {/foreach}
        
    {/if}
    </fieldset>
    <fieldset>
    <legend>Payment Method</legend>
    {* Select Payment System in same way, only if its count > 1 *}
    {if $smarty.request.hide_paysys }
        <input type="hidden" name="paysys_id" value="{$smarty.request.hide_paysys|escape}" />
        <input type="hidden" name="hide_paysys" value="{$smarty.request.hide_paysys|escape}" />
    {else}
    {if $config.product_paysystem}{else}
    {if count($paysystems)>1}
    
    <table>
            {foreach from=$paysystems item=p} 
    		<tr>
    		<td><input type="radio" id="paysys_id{$p.paysys_id}" name="paysys_id" value="{$p.paysys_id|escape}"
                {if $p.paysys_id eq $smarty.request.paysys_id }checked{/if}
                 /></td>
    			 <td><label for="paysys_id{$p.paysys_id}"><b>{$p.title} - </b>
                <small>{$p.description}</small></label></td>
    		</tr>
            {/foreach}
    		</table>
        
    {else}{* There is only one payment system enabled *}
    <p>&nbsp;</p>
    <p><strong>Payment Options</strong></p>
            {foreach from=$paysystems item=p} 
            <p><label for="paysys_id">{$p.title}</label> - {$p.description}</p>
            <input type="hidden" name="paysys_id" id="paysys_id" value="{$p.paysys_id|escape}" />
            {/foreach}
        
    {/if}
    {/if}
    {/if}
    
    
      </fieldset>
       <fieldset>
       <legend>Personal Information</legend>
           <table id="signup">
    	<tr>
    	  <td width="35%"><label for="name_f">First Name</label></td>
    		<td width="35%"><input type="text" name="name_f" id="name_f" value="{$smarty.request.name_f|escape}" maxlength="30" /></td>
    		<td width="30%"></td>
    	</tr>
    	<tr>
    		<td><label for="name_l">Last Name</label></td>
    		<td><input type="text" name="name_l" id="name_l" value="{$smarty.request.name_l|escape}" maxlength="30" /></td>
        	<td></td>
    	</tr>
    	<tr>
    		<td><label for="email">E-Mail Address </label></td>
    		<td><input type="text" name="email" id="email" value="{$smarty.request.email|escape}" maxlength="30" />
    		</td>
    		<td>
    		<span class="small blue"><strong>Your email address will be your username to log into the site.</strong></span></td>
    		
    	
    
    
    	</tr>
    	<tr valign="top">
    {if not $config.generate_pass}
    	  <td><label for="pass0">Choose a Password</label></td>
    	  <td><input type="password" name="pass0" id="pass0" value="{$smarty.request.pass0|escape}" maxlength="30" /> <a href="" title="Must be {$config.pass_min_length} or more characters">?</a></td>
    		<td></td>
    	</tr>
    	<tr>
    		<td><label for="pass1">Confirm your password</label></td>
    		<td><input type="password" name="pass1" id="pass1" value="{$smarty.request.pass1|escape}" maxlength="30" /></td>
    		<td></td>   
    	</tr>
        
    {/if}
    
    {$additional_fields_html}
    
    {if $config.use_address_info}
    
    	<tr>
    		<td><label for="street">Street</label></td>
    		<td><input type="text" id="street" name="street" value="{$smarty.request.street|escape}" size="30" maxlength="30" /></td>
    		<td></td>
    	</tr>
    
    	<tr>
    		<td><label for="city">City</label></td>
    		<td><input type="text" id="city" name="city" value="{$smarty.request.city|escape}" size="30" maxlength="30" /></td>
    		<td></td>
    	</tr>
        
    	<tr>
    		<td><label for="state">State</label></td>
    		<td><select name="state" id="state" size="1" />
        {html_options options=$config.state_options selected=$smarty.request.state}
        </select></td>
    		<td></td>
    	</tr>
    	
        <tr>
    		<td><label for="zip">ZIP</label></td>
    		<td><input type="text" id="zip" name="zip" value="{$smarty.request.zip|escape}" size="6" maxlength="15" /></td>
    		<td></td>
    	</tr>
    	
    	<tr>
    		<td><label for="country">Country</label></td>
    		<td><select name="country" id="country" size="1" />
        {html_options options=$config.country_options selected=$smarty.request.country}
        </select></td>
    		<td></td>
    	</tr>
           
    	<tr>
    		<td><label for="i_agree">I agree with the<br /><a href="tos.php">Terms of Service</a></label></td>
    		<td colspan="2"><input type="checkbox" id="i_agree" name="i_agree" value="1" />
    </td>
    		
    	</tr>
    	   
    {/if}
    </table>
    </fieldset>
    	 
    {if $config.use_coupons}
    <fieldset>
    <legend>Coupons</legend>
    <table width="100%">
    	<tr>
    		<td><label for="coupons">Enter coupon code</label></td>
    		<td><input type="text" name="coupon" id="coupons" value="{$smarty.request.coupon|escape}" size="30" /></td>
    		
    	</tr>
    </table>
    </fieldset>    
        
    {/if}
    
    <input type="hidden" name="do_payment" value="1" />
    <input type="hidden" name="price_group" value="{$smarty.request.price_group|escape}" />
    <input type="submit" value="Continue" />
    
    </form>
    
    </div>
    
    
    {include file="footer.html"}
    

Share This Page