jQuery(document).ready(function($) { // Start of jQuery document ready function //----------------------------------------------------------------------------- function createRequest() { try { request = new XMLHttpRequest(); } catch (tryMS) { try { request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (otherMS) { try { request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (failed) { request = null; } } } return request; } // alert('New instance'); // console.log('New Instance'); $(function() { $( "#record_status_dialog" ).dialog({ modal: true, autoOpen: false, open: function(event, ui) { // It'll hide Close button $(".ui-dialog-titlebar-close", ui.dialog | ui).hide(); }, hide: "puff", show : "slide", width: 650, height:100 }) }); // beforeShowDay : $.datepicker.noWeekends, $("#txtMeetingSDate").live('mouseenter focusin',function() { $(this).datepicker({ firstDay : 1, dateFormat : "yy-mm-dd", changeMonth : true, changeYear : true, minDate : "-0D", maxDate : "+365D", showOtherMonths : true, selectOtherMonths: true }) }); $("#txtMeetingEDate").live('mouseenter focusin',function() { $(this).datepicker({ firstDay : 1, dateFormat : "yy-mm-dd", changeMonth : true, changeYear : true, minDate : "-0D", maxDate : "+365D", showOtherMonths : true, selectOtherMonths: true }) }); $('#txtAddlNotes').live('click',function(){ $('#txtAddlNotes').val(''); }); $('#txtVendors').live('click',function(){ $('#txtVendors').val(''); }); $('#mtgSubButton').live('click',function(){ var region = $("#mr_region").val(); if(region == 'X') { alert('Please select region'); return false; } var local = $.trim($('#mr_mtg_local').val()).length; if(local < 4) { alert('Please enter local'); $('#txtLocal').focus().select(); return false; } /* var unit = $.trim($('#txtUnit').val()); if(unit.length < 6 && unit.length > 0) { alert('Invalid Unit, format : 755002, re-enter'); $('#txtUnit').focus().select(); return false; } if(unit.length > 0) { var re = /[^0-9]/; if (re.test(unit)){ // found a non-numeric value, handling error alert('Invalid Unit, numeric values only, re-enter'); $('#txtUnit').focus().select(); return false; } } */ var mtg_type = $("#mr_mtg_type").val(); if(mtg_type == 'X') { alert('Please select an Event Type'); return false; } var openMeeting = $("#mr_mtg_open").val(); if(openMeeting == "N") { var vendorsRequested = $.trim($("#txtVendors").val()); if(vendorsRequested.length == 0 || vendorsRequested == "Enter requested vendors here") { alert('Please enter Requested Vendors or change meeting to all CSEA Endorsed Member Benefit vendors'); return false; } } var address = $.trim($('#txtAddr1').val()); if(address.length < 1) { alert('Please enter address'); $('#txtAddr1').focus().select(); return false; } var city = $.trim($('#txtCity').val()); if(city.length < 1) { alert('Please enter city'); $('#txtCity').focus().select(); return false; } var state = $.trim($('#txtState').val()); if(state.length < 2 || state.length > 2) { alert('Please enter state'); $('#txtState').focus().select(); return false; } var zip = $.trim($('#txtZip').val()); if(zip.length < 5 || zip.length > 5) { alert('Invalid Zip Code, format : 12210, re-enter'); $('#txtZip').focus().select(); return false; } if(zip.length == 5) { var re = /[^0-9]/; if (re.test(zip)){ // found a non-numeric value, handling error alert('Invalid Zip Code, numeric values only, re-enter'); $('#txtZip').focus().select(); return false; } } var meetingSDate = $('#txtMeetingSDate').val(); if(meetingSDate == 'Enter Meeting Start Date') { alert('Must enter meeting start date'); return false; } var meetingEDate = $('#txtMeetingEDate').val(); if(meetingEDate == 'Enter Meeting End Date') { alert('Must enter meeting end date'); return false; } var attending = $.trim($('#mr_mtg_attending').val()); var re = /[^0-9]/; if(re.test(attending) || attending.length < 1) { alert('Invalid number of attendees; re-enter'); $('#mr_mtg_attending').focus().select(); return false; } var rsvpName = $.trim($('#txtRSVPname').val()); var re = /[0-9]/; if(re.test(rsvpName) || rsvpName.length < 1) { alert('Invalid RSVP Name; re-enter'); $('#txtRSVPname').focus().select(); return false; } var rsvpPhone = $.trim($('#txtRSVPphone').val()); var re = /[^0-9]/; if(re.test(rsvpPhone) || rsvpPhone.length != 10) { alert('Invalid RSVP Phone; Must be 10 digits only; re-enter'); $('#txtRSVPphone').focus().select(); return false; } var emailAddress = $.trim($('#txtRSVPemail').val()); var emailRegex = new RegExp(/^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$/i); var valid = emailRegex.test(emailAddress); if (!valid || emailAddress.length < 1) { alert("Invalid e-mail address; re-enter"); $('#txtRSVPemail').focus().select(); return false; } // email from here down var dataString = $("#meeting_request_form").serialize(); $.ajax({ type:'POST', url: 'https://cseany.org/?page_id=631660', data: dataString }) .done(function(data){ /////////////////////////// // document.write(data); // /////////////////////////// var dataValue=$.trim(data); if(dataValue != "SUCCESS") { //var dialogData = " --- Error sending request; see I.T. department."; var dialogData = " --- Request sent. --- "; $("#record_status_dialog").html(dialogData); $("#record_status_dialog").dialog("open"); } else { var dialogData = " --- Request sent. --- "; $("#record_status_dialog").html(dialogData); $("#record_status_dialog").dialog("open"); } setTimeout(function() { $("#record_status_dialog").dialog("close"); $('#meeting_request_form').trigger("reset"); $('#spanVendors').hide(); },2500); return; }) .fail(function(xhr, desc, err) { // just in case posting the form fails var dialogData = "meetingEmail.php failed; see I.T. department."; $("#record_status_dialog").html(dialogData); $("#record_status_dialog").dialog("open"); setTimeout(function() { $("#record_status_dialog").dialog("close"); $('#meeting_request_form').trigger("reset"); $('#spanVendors').hide(); },5000); return; }); return false; }); $('#mr_mtg_open').on('change', function() { var endorsedVendors = $("#mr_mtg_open").val(); $("#txtVendors").val('Enter requested vendors here'); if(endorsedVendors == 'N') { $('#spanVendors').show(); } else { $('#spanVendors').hide(); } }); return false; /////////////////////////////////////////////// }); // End of jQuery document ready function // /////////////////////////////////////////////// |