$(function() { $('form').submit(function() { $('.date-pick').each(function(index) { var str = $(this).attr('value'); if (str) { var convert = str.replace(/(\d{2})[-|/](\d{2})[-|/](\d{4})/, "$3-$1-$2"); $(this).attr('value',convert); } }); if ($("#checkme").is(":checked")) { console.log($("select#meta_5fsp_5ftype option:selected").val); if (!$("select[name='meta_sp_type']").val()) { alert('Please select your service provider type'); return false; } } if ($("input[name='meta_Auth_Sig_Eligible#_set_1']").length > 0 && !$("input[name='meta_Auth_Sig_Eligible#_set_1']").is(':checked')) { alert('Eligibility Authorization checkbox must be checked'); return false; } if ($("#auth_sig_container").length > 0 && $("input[name='meta_Auth_Sig_Approved#_set_1']").length > 0 && !$("input[name='meta_Auth_Sig_Approved#_set_1']").is(':checked')) { alert('Approval Authorization checkbox must be checked'); return false; } }); if ($("#checkme").is(":checked")) { $("#sp").css("display","block"); } else { $("#sp").css("display","none"); } // add onclick handler to checkbox w/id checkme $("#checkme").click(function() { if ($("#checkme").is(":checked")) { $("#sp").show("fast"); } else { $("#sp").hide("fast"); $("#sp :input:not(:button)").val([]); $("#sp :input").val("") } }); });