function limitText(limitField, limitNum) { if (limitField.val().length > limitNum) { limitField.val(limitField.val().substring(0, limitNum)); } } // var execption = /^[A-Za-z0-9!?\. -,'&():|"+@%]*(.*)/.exec(str)[1]; // var result = /^([A-Za-z0-9!?\. -,'&():|"+@%]*)(.*)/.exec(str); $(function() { // validations(); var elem = $("#chars"); $("#id_phone_number").mask("(999) 999-9999"); $("#id_alternate_phone").mask("(999) 999-9999"); $("#id_fax_number").mask("(999) 999-9999"); $("#set_all").click(all_days_same); $("#set_MF").click(all_MF); $("#set_clear").click(clear_times); $.each(['sunday','monday','tuesday','wednesday','thursday','friday','saturday'], function(i, day) { $("#id_hours_"+day+"_close").insertAfter("#id_hours_"+day+"_open"); }); $("#id_hours_sunday_close").after("   [Apply To All]"); $("#id_hours_monday_close").after("   [Set Monday-Friday]"); $("#set_all").click(all_days_same); $("#set_MF").click(all_MF); $("#set_clear").click(clear_times); $("#how").click(function(){$(".how").toggle();}); $("#id_localeze_categories").select2({ maximumSelectionSize: 3 }); $("#id_payment_types_commadelimited_0").click(clear_payment_types); $("#id_payment_types_commadelimited_1").click(check_payment_types); $("#id_payment_types_commadelimited_2").click(check_payment_types); $("#id_payment_types_commadelimited_3").click(check_payment_types); $("#id_payment_types_commadelimited_4").click(check_payment_types); $("#id_payment_types_commadelimited_5").click(check_payment_types); $("#id_payment_types_commadelimited_6").click(check_payment_types); $("#id_payment_types_commadelimited_7").click(check_payment_types); $("#id_payment_types_commadelimited_8").click(check_payment_types); $("#id_payment_types_commadelimited_9").click(check_payment_types); $("#id_open247").click(open247); }); var open247 = function(){ if( $(this).is(":checked")){ $("select[id*=day_open]").prop('disabled', 'disabled'); $("select[id*=day_close]").prop('disabled', 'disabled'); $("#set_all").unbind("click"); $("#set_MF").unbind("click"); clear_times(); } else { $("select[id*=day_open]").prop('disabled', ''); $("select[id*=day_close]").prop('disabled', ''); $("#set_all").click(all_days_same); $("#set_MF").click(all_MF); } }; var clear_payment_types = function(){ var unchecked = true; for (var i = 1; i <= 9; i++){ $("#id_payment_types_commadelimited_"+i).prop("checked",""); } }; var check_payment_types = function(){ var unchecked = true; for (var i = 1; i <= 9; i++){ if ($("#id_payment_types_commadelimited_"+i).is(":checked")){ $("#id_payment_types_commadelimited_0").prop("checked",""); unchecked = false; } } if (unchecked){ $("#id_payment_types_commadelimited_0").prop("checked","checked"); } }; var all_days_same = function(){ var open_time = $("#id_hours_sunday_open").val(); var close_time = $("#id_hours_sunday_close").val(); $("select[id*=day_open]").val(open_time); $("select[id*=day_close]").val(close_time); return false; }; var all_MF = function(){ var open_time = $("#id_hours_monday_open").val(); var close_time = $("#id_hours_monday_close").val(); $("select[id*=day_open]:not(select[id*=sunday]):not(select[id*=saturday])").val(open_time); $("select[id*=day_close]:not(select[id*=sunday]):not(select[id*=saturday])").val(close_time); return false; }; var clear_times = function(){ var open_time = ""; var close_time = ""; $("select[id*=day_open]").val(open_time); $("select[id*=day_close]").val(close_time); };