function fCheckEmail() { if(validateEmail($("#sRegisterEmail").val())) { $.ajax({ type: 'post', url: 'ajax/check-email.php', data: {sRegisterEmail:$("#sRegisterEmail").val()} }).success(function(response){ if(response.indexOf("yes")>=0) { $("#emailUnavailable").show(); $("#emailAvailable").hide(); } else { $("#emailUnavailable").hide(); $("#emailAvailable").show(); } }); } else { $("#emailUnavailable").hide(); $("#emailAvailable").hide(); return false; } } function fCheckRegister() { if($("#emailAvailable").is(":visible")) { if($("#sRegisterPassword").val()==$("#sRegisterConfPassword").val()) { return true; } else { alert("The two passwords you entered do not match. Please check to make sure your passwords are typed in correctly."); return false; } } else { alert("That email address is invalid, please choose another."); return false; } } function validateEmail(email) { var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; return re.test(email); } $(document).ready(function() { // the function that is run when you click the "same as billing" checkbox $("#sRegisterSameAsBilling").change(function(){ if(this.checked) { // loop everything beginning with sRegisterBilling and copy over to sRegisterBilling $("[name^=sRegisterBilling]").each(function(){ $("[name=sRegisterDelivery"+$(this).attr('name').replace("sRegisterBilling","")+"]").val($(this).val()); }); // loop everything beginning with nRegisterBilling and copy over to nRegisterBilling $("[name^=nRegisterBilling]").each(function(){ $("[name=nRegisterDelivery"+$(this).attr('name').replace("nRegisterBilling","")+"]").val($(this).val()); }); // disable the delivery input boxes $("[name^=sRegisterDelivery]").each(function(){$(this).prop("disabled","disabled");}); $("[name^=nRegisterDelivery]").each(function(){$(this).prop("disabled","disabled");}); } else { // enable the delivery input boxes $("[name^=sRegisterDelivery]").each(function(){$(this).prop("disabled","");}); $("[name^=nRegisterDelivery]").each(function(){$(this).prop("disabled","");}); } }); });