// prepare the form when the DOM is ready jQuery(document).ready(function() { try { var options0 = { beforeSubmit: gm_formvalidate0, success: gm_showResponse }; jQuery('#dr_iletisim_formu').ajaxForm(options0); } catch (e) { } }); // pre-submit callback function gm_formvalidate0(formData, jqForm) { var error = false; var error_message = ''; var fcontact_email = jQuery("#contact_email").fieldValue(); if (!validateRequired(fcontact_email,"") || !validateEmail(fcontact_email)) { jQuery("#contact_email").addClass("gm_err_field"); if (error == false) { jQuery("#contact_email").focus(); error = true; } error_message = error_message + "e-Posta adresi field must be filled out, please enter a valid email.\n\n"; } else { jQuery("#contact_email").removeClass("gm_err_field"); } var fcontact_text = jQuery("#contact_text").fieldValue(); if (!validateRequired(fcontact_text,"")) { jQuery("#contact_text").addClass("gm_err_field"); if (error == false) { jQuery("#contact_text").focus(); error = true; } error_message = error_message + "Mesajinizi girin field must be filled out.\n\n"; } else { jQuery("#contact_text").removeClass("gm_err_field"); } if(jQuery("#dr_iletisim_formu_captcha").fieldValue().length > 0) { var captcha_result = 0; var captcha_result = check_gm_captcha("dr_iletisim_formu"); if(captcha_result == "0" || captcha_result == 0 ) { jQuery("#dr_iletisim_formu_captcha").addClass("gm_err_field"); if (error == false) { jQuery("#dr_iletisim_formu_captcha").focus(); error = true; } error_message = error_message + "Invalid Captcha.\n\n"; } else { jQuery("#dr_iletisim_formu_captcha").removeClass("gm_err_field"); } } if (error == true) { alert(error_message); return false; } else { return true; } } // post-submit callback try { function gm_showResponse(responseText, statusText) { eval(responseText); } } catch (e) { } /* 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); } jQuery().ajaxSend(jQuery.blockUI).ajaxStop(jQuery.unblockUI);