* required fields
jQuery(function(){ var plugin_form_clicked = false; var plugin_form_fields = {"name":"Your Name","email":"Your Email","type":"Department","subject":"Subject","new_ticket_message":"Your Message"}; var plugin_email_fields = {"email":"Your Email"}; var plugin_error_fields = [];
var plugin_form_frm = jQuery('#_plugin_form_e1b1f2629366d236121f91a3d1e7b810').parents('form'); if(typeof plugin_form_frm == 'undefined' || !plugin_form_frm){ alert('Form Plugin initialisation failed. Contact developer.'); return; } jQuery(':submit',plugin_form_frm).mousedown(function() { plugin_form_clicked = this; }); // loop through all applicable input options and apply required javascript/class jQuery('input,textarea,select',plugin_form_frm).each(function(){ var n = jQuery(this).attr('name'); var attr_type = (jQuery(this).attr('type')+'').toLowerCase(); if(attr_type == 'hidden')return; if(typeof plugin_form_fields[n] != 'undefined'){ jQuery(this).addClass('plugin_form_required'); jQuery(this).after(' *'); } if(typeof plugin_email_fields[n] != 'undefined'){ jQuery(this).addClass('plugin_form_required_email'); } if(typeof plugin_error_fields[n] != 'undefined'){ jQuery(this).addClass('dtbaker_error_field'); } }); jQuery(plugin_form_frm).submit(function(){ // check required fields on submit if(plugin_form_clicked && (jQuery(plugin_form_clicked).attr('name').match(/cancel/i) || jQuery(plugin_form_clicked).attr('name').match(/butt_del/i))){ jQuery('#_plugin_form_e1b1f2629366d236121f91a3d1e7b810').after(''); return true; } var plugin_form_error = false; jQuery('.plugin_form_required',this).each(function(){ if(!jQuery(this)[0].disabled && (jQuery(this).hasClass('plugin_form_required_email'))){ var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; var address = jQuery(this).val(); if(!reg.test(address)) { jQuery(this).addClass('dtbaker_error_field'); if(!plugin_form_error){ // focus first element. jQuery(this)[0].focus(); } plugin_form_error = true; var chge = function(){ if(reg.test(jQuery(this).val())){ jQuery(this).removeClass('dtbaker_error_field'); }else{ jQuery(this).addClass('dtbaker_error_field'); } }; jQuery(this).keyup(chge).change(chge); } } if(!jQuery(this)[0].disabled && (jQuery(this).val() == '' || !jQuery(this).val())){ jQuery(this).addClass('dtbaker_error_field'); if(!plugin_form_error){ // focus first element. jQuery(this)[0].focus(); } plugin_form_error = true; var chg = function(){ if(jQuery(this).val() != '' || jQuery(this).val()){ jQuery(this).removeClass('dtbaker_error_field'); }else{ jQuery(this).addClass('dtbaker_error_field'); } }; jQuery(this).keyup(chg).change(chg); } }); if(plugin_form_error){ // show error message alert('Required fields missing, please complete required fields.'); /*jQuery('#plugin_form_header_e1b1f2629366d236121f91a3d1e7b810').html('
Alert: Required fields missing.
');*/ } return !plugin_form_error; }); });