{* factory_template_register *}

{* validation js *}

{capture assign='validation_rules'}
{literal}
    $.extend($.validator.messages, {
        required: "{/literal}{$upcoupon->lang('js_required')}{literal}",
        email: "{/literal}{$upcoupon->lang('js_email')}{literal}",
        number: "{/literal}{$upcoupon->lang('js_number')}{literal}",
        minlength: "{/literal}{$upcoupon->lang('js_minlength')}{literal}" 
    });
    
    $("#{/literal}{$full_form_id}{literal}").validate({
        errorElement: "span",
        errorPlacement: function(error, element) {
             error.insertAfter(element.closest("span"));  
        },
        groups: {
            coupon_code_parts: "{/literal}{$form_id}{literal}coupon_code_01 {/literal}{$form_id}{literal}coupon_code_02 {/literal}{$form_id}{literal}coupon_code_03 {/literal}{$form_id}{literal}coupon_code_04"   
        },
        messages: {
            {/literal}{$form_id}{literal}coupon_code_01: {
                minlength: "{/literal}{$upcoupon->lang('js_minlength_multiple')}{literal}"
            },
            {/literal}{$form_id}{literal}coupon_code_02: {
                minlength: "{/literal}{$upcoupon->lang('js_minlength_multiple')}{literal}"
            },
            {/literal}{$form_id}{literal}coupon_code_03: {
                minlength: "{/literal}{$upcoupon->lang('js_minlength_multiple')}{literal}" 
            },
            {/literal}{$form_id}{literal}coupon_code_04: {
                minlength: "{/literal}{$upcoupon->lang('js_minlength_multiple')}{literal}"
            }
            
        },
        rules: {
            {/literal}{$form_id}{literal}first_name: "required",
            {/literal}{$form_id}{literal}last_name: "required",
            {/literal}{$form_id}{literal}email: {
            required: true,
            email: true
        },
            {/literal}{$form_id}{literal}phone: {
                required: true,
                number: true,
                minlength: 10
            },
            {/literal}{$form_id}{literal}coupon_code_01: {
                required: true,
                number: true,
                minlength: 4
            },
            {/literal}{$form_id}{literal}coupon_code_02: {
                required: true,
                number: true,
                minlength: 4
            },
            {/literal}{$form_id}{literal}coupon_code_03: {
                required: true,
                number: true,
                minlength: 4
            },
            {/literal}{$form_id}{literal}coupon_code_04: {
                required: true,
                number: true,
                minlength: 4
            },
            {/literal}{$form_id}{literal}terms_and_conditions: "required"
        }
    });
{/literal}
{/capture}


{literal}
<script type="text/javascript">

$.validator.setDefaults({
	//submitHandler: function() { alert("verstuurd"); }
});

$().ready(function() {
        {/literal}{$validation_rules}{literal}
});

</script>

{/literal}

{* /validation js *}

<hr />

{$startform}
{$hidden}

{if $is_registered == '1'}
    {$s_s_coupon_code_registered_text} <br /><br />

{$delete_coupon_code_cookie_text} <br /><br />

<a href="{$delete_coupon_code_cookie_link}">{$delete_text}</a><br /><br />
    
{/if}

<fieldset class="mainform">

<span class="header">{$register_coupon_code_text}<br /><br /></header>

<div class="row">
<label for="first_name">{$first_name_text}:</label>
<span class="bg">{$first_name_input}</span>
{if isset($error_array.first_name)}
<span class="error">{$upcoupon->lang('js_required')}</span>
{/if}
</div>

<div class="row">
<label for="last_name">{$last_name_text}:</label>
<span class="bg">{$last_name_input}</span>
{if isset($error_array.last_name)}
<span class="error">{$upcoupon->lang('js_required')}</span>
{/if}
</div>

<div class="row">
<label for="email">{$email_text}:</label>
<span class="bg">{$email_input}</span>
{if isset($error_array.email)}
<span class="error">{$upcoupon->lang('js_email')}</span>
{/if}
</div>

<div class="row">
<label for="phone">{$phone_text}:</label>
<span class="bg">{$phone_input}</span>
{if isset($error_array.phone)}
<span class="error">{$upcoupon->lang('js_number')}</span>
{/if}
</div>

<div class="row">
<label for="coupon_code">{$coupon_code_text}:</label>
<span class="bg">{$coupon_code_01_input}{$coupon_code_02_input}{$coupon_code_03_input} {$coupon_code_04_input}</span>
{if isset($error_array.coupon_code)}
<span class="error">{$upcoupon->lang('js_number')}</span>
{/if}
</div>

<div class="row">
<label for="terms_and_conditions">{$terms_and_conditions_text}:</label>
<span class="bg">{$terms_and_conditions_input}</span>
<span class="txt">&nbsp; <a href="#">{$terms_and_conditions_agree_text}</a></span>
{if isset($error_array.terms_and_conditions)}
<span class="error">{$upcoupon->lang('js_required')}</span>
{/if}
</div>

<div class="row">
<label for="newsletter">{$newsletter_text}:</label>
<span class="bg">{$newsletter_input}</span>
<span class="txt">&nbsp; <a href="#">{$newsletter_agree_text}</a></span>
{if isset($error_array.newsletter)}
<span class="error">{$upcoupon->lang('js_optional')}</span>
{/if}
</div>

<div class="row">
<label>&nbsp;</label>
<span class="button-container">{$submit}</span>
</div>

</fieldset>

{$endform}

<hr />

{* /factory_template_register *}
