// prepare the form when the DOM is ready $(document).ready(function() { var options0 = { beforeSubmit: gm_formvalidates0, success: gm_showResponses }; $('#recommendUsForm').ajaxForm(options0); }); // pre-submit callback function gm_formvalidates0(formData, jqForm) { var error = false; var error_message = ''; var fname = $("#ru_name").fieldValue(); if (!validateRequired(fname,"")) { $("#ru_name").addClass("gm_err_field"); if (error == false) { $("#name").focus(); error = true; } error_message = error_message + "Your Name field must be filled out.
"; } else { $("#ru_name").removeClass("gm_err_field"); } var femail = $("#ru_email").fieldValue(); if (!validateRequired(femail,"") || !validateEmail(femail)) { $("#ru_email").addClass("gm_err_field"); if (error == false) { $("#email").focus(); error = true; } error_message = error_message + "Your Email field must be filled out, please enter a valid email.
"; } else { $("#ru_email").removeClass("gm_err_field"); } if (error == true) { $("#ru_submissionResultCell").show(); $('#ru_submissionResultCell').html(error_message); return false; } else { $('#ru_submissionResultCell').html(""); $("#ru_submissionResultCell").hide(); $('div.formElementCell').block('
Please wait...
', { border: '2px solid #a00'}); return true; } } // post-submit callback function gm_showResponses(responseText, statusText) { eval(responseText); $('div.formElementCell').unblock(); } /* VALIDATION FUNCTIONS */ function validateRequired(fieldValue,ignoreValue) { if (fieldValue == "" || fieldValue == ignoreValue ) { return false; } else { return true; }} function validateEmail(fieldValue, fieldObj) { if (fieldValue == "") return true; return /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(fieldValue); } function validateNumber(fieldValue, fieldObj) { if (fieldValue == "") return true; /* return (parseFloat(val,10)==(fieldValue*1)); return (!isNaN(fieldValue) && !/^\s+$/.test(fieldValue)); */ return /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(fieldValue); } function validateDigit(fieldValue, fieldObj) { if (fieldValue == "") return true; return !/[^\d]/.test(fieldValue); } function validateAlphanum(fieldValue, fieldObj) { if (fieldValue == "") return true; return !/\W/.test(fieldValue); } /* $().ajaxSend($.blockUI).ajaxStop($.unblockUI); */ $(document).ready(function(){ // cache the embedded content used as message var formElement = $('#recommendUsCell'); $('.recommendus_trigger').click(function() { //$.blockUI(formElement, { width: '380px', top:'20%', left:'40%' }); $.blockUI({ message: formElement }); return false; }); $('#ru_close_form').click($.unblockUI); }); function alertdefault(page){ alert('Your friend recommended that you visit the following page on our website: '+ page); }