$('.offer-select').click(function(e){ if($(this).children('input').val()=="pro"){ $('.offer-duration').show(); $('.offer-payment-type').show(); } else{ $('.offer-duration').hide(); $('.offer-payment-type').hide(); } $('.offer-type-hidden').val($(this).children('input').val()); e.preventDefault(); $('.sub-form').fadeIn(500); $(".offer-select").children('input').prop('checked',false); $(this).children('input').prop('checked',true); }); $('.plan-form').validate({ errorPlacement: function(error, element) { error.insertBefore(element); }, rules: { lastName:{ required: true, minlength: 1, maxlength: 55 }, postalCode:{ required: true, minlength: 3, maxlength: 20, }, city:{ required: true, minlength: 1, maxlength: 255 }, country:{ required: true, minlength: 1, maxlength: 255 }, street:{ required: true, minlength: 7, maxlength: 255 }, name:{ required: true, minlength: 1, maxlength: 50 }, firstName:{ required: true, minlength: 1, maxlength: 55 }, newPassword:{ required: true, minlength: 6, maxlength: 30, }, phone: { required: true, minlength: 5, }, newPasswordConfirmation: { equalTo: "#passwordf" } }, submitHandler: function() { $('.offer-validate').addClass("disabled").attr("disabled",true); $.post("pages/subscribe.action.php",$('.plan-form').serialize()+"&action=createAccount",function(data){ $('.offer-validate').removeClass("disabled").attr("disabled",false); if(data.code==0){ clear_form_elements('.plan-form'); $('.sub-form').fadeOut(500); showInfo(data.msg,"success"); } else if(data.code==1){ showInfo(data.msg,"failure"); } else{ if($('#payment-type').val()=='payment_check') window.location = "informations-paiement-cheque.html"; else window.location = "informations-paiement.html"; } },"json") } }); $('.cgv-check').change(function(){ if($(this).is(':checked')){ $('.offer-validate').removeClass('disabled').attr("disabled",false); } else{ $('.offer-validate').addClass('disabled').attr("disabled",true); } }) $(function() { $('.feature-listing').tooltip(); }); function clear_form_elements(ele) { $(ele).find(':input').each(function() { switch(this.type) { case 'password': case 'select-multiple': case 'select-one': case 'text': case 'textarea': $(this).val(''); break; case 'checkbox': case 'radio': this.checked = false; } }); }