jQuery(document).ready(function() { var username = jQuery('#username'); var email = jQuery('#email'); var ubox = jQuery('#usernamemsg'); var ebox = jQuery('#emailmessage'); jQuery(username).blur(function(){ jQuery.ajax({ url: "index.php?option=com_p4a&format=raw&task=checkusername&username="+jQuery(username).val(), type: "post", dataType: 'json', // callback handler that will be called on success success: function(res){ if(res.msg == "false") { //submit jQuery('input[type="submit"]').attr('disabled','disabled'); //jQuery(".button").attr("disabled","disabled"); } else { jQuery('input[type="submit"]').removeAttr("disabled"); } jQuery(ubox).html(res.html); } }); }); jQuery(email).blur(function(){ jQuery.ajax({ url: "index.php?option=com_p4a&format=raw&task=checkemail&email="+jQuery(email).val(), type: "post", dataType: 'json', // callback handler that will be called on success success: function(res){ if(res.msg == "false") { jQuery('input[type="submit"]').attr('disabled','disabled'); } else { jQuery('input[type="submit"]').removeAttr("disabled"); } jQuery(ebox).html(res.html); } }); }); }); function validateform( f ) { error = ''; if (f.username.value.length == 0) { error += "* You must enter a username.\n"; } if (f.firstname.value.length == 0 || f.lastname.value.length == 0) { error += "* Your name is required.\n"; } if (f.address.value.length == 0 || f.city.value.length == 0 || (f.country.value == 'US' && f.state.value.length == 0) || f.postalcode.value.length == 0) { error += "* Your complete address is required.\n"; } if (f.email.value.length == 0) { error += "* Your e.mail address is required.\n"; } else { if (! emailCheck( f.email.value )) { error += "* Your e.mail address is not valid.\n"; } } if (f.email.value != f.email2.value) { error += "* Your e.mail address and confirmation e.mail address do not match.\n"; } if (f.password.value.length == 0) { error += "* You must enter a password.\n"; } if (f.password.value != f.password2.value) { error += "* Your password and confirm password do not match.\n"; } if (f.usertype.selectedIndex == 0) { error += "* Please choose a category.\n"; } if (f.legal.checked==false) { error += "* You must agree to the legal terms.\n"; } if (!(f.access[1].checked || f.access[2].checked || f.access[3].checked)) { error += "* Sorry, you must choose a subscription type.\n"; } if (f.access[1].checked && f.auto_renew.checked) { error += "* Sorry, you may not auto-renew a 24-hour subscription.\n"; f.auto_renew.checked = false; } if (f.access[2].checked && f.auto_renew.checked) { error += "* Sorry, you may not auto-renew a 15-day subscription.\n"; f.auto_renew.checked = false; } if (error.length > 0) { alert(error); return false; } else { // If there is a special offer code, we need to submit to // a validation page. Otherwise, just submit normally // (as per IM from jcastle on 7/14/2009) // alert('Submit: specoffercode=' + f.specoffercode.value); if (f.specoffercode.value != '') { f.action = "index.php?option=com_p4a&view=specialoffer"; //return false; } else { f.action = "index.php?option=com_p4a&task=save"; //f.action = "https://www.prices4antiques.com/secure/ccprocessse.asp"; } //alert('Action=' + f.action); return true; } } function emailCheck( email ) { // prefunctory email sanity check. Make sure it *looks* ok. // Can't have any spaces if (email.indexOf(" ") >= 0 || email.indexOf("\t") >= 0) { return 0; } // Can't have any square brackets either if (email.indexOf("[") >= 0 || email.indexOf("]") >= 0) { return 0; } // Needs to have an @ in it, somewhere AFTER the first character. atpos = email.indexOf("@"); if (atpos < 1) { return 0; } // Should have a least one dot somewhere in the host part, // AFTER the first character. hostpart = email.substring(atpos+1,email.length); if (hostpart.indexOf(".") < 1) { return 0; } return 1; }