$(document).ready(function() { addServiceCatRow(); changeSignatureChk(); $("#btnRemoveRow").prop("disabled", true); $("#btnSubmit").prop("disabled", false); $('#txtCompanyName').focus(); disableEnterKey(); }); $(function() { // validate the comment form when it is submitted $("#frmVendorRequest").validate({ rules: { txtCompanyName: { required: true, }, txtCompanyAddress1: { required: true, }, txtCompanyCity: { required: true, }, txtCompanyState: { required: true, }, txtCompanyZip: { required: true, }, txtContactName: { required: true, }, txtEmergencyPhone: { required: true, }, txtBusinessPhone: { required: true, }, txtEmailAddy: { required: true, email: true, }, txtWebsite: { url: true, }, txtSignatureBox: { required: true, }, }, messages: { txtCompanyName: { required: "Please enter Company Name", }, txtCompanyAddress1: { required: "Please enter Company Address", }, txtCompanyCity: { required: "Please enter Company City", }, txtCompanyState: { required: "Please select Company State", }, txtCompanyZip: { required: "Please enter Company Zip Code", }, txtContactName: { required: "Please enter Contact Name", }, txtEmergencyPhone: { required: "Please enter Emergency Phone Number", }, txtBusinessPhone: { required: "Please enter Business Phone Number", }, txtEmailAddy: { required: "Please enter Contact Email Address", email: "That doesn't appear to be a valid email address", }, txtWebsite: { url: "Please enter a valid URL (e.g., http://whatever.com)", }, txtSignatureBox: { required: "Please mark checkbox and enter your Full Legal Name", }, }, }); $.validator.addMethod("requiredslctServiceCategory", $.validator.methods.required, "Please select appropriate Service Category and enter a Description"); $.validator.addClassRules("cssServiceCategory", { requiredslctServiceCategory: true, }); $.validator.addMethod("requiredtxtaDescription", $.validator.methods.required, "Please select appropriate Service Category and enter a Description"); $.validator.addClassRules("cssDescription", { requiredtxtaDescription: true, }); $("#btnAddRow").click(function () { updateNumCreatedRows("txtNumCreatedRows", 1); addServiceCatRow(); if ($("#txtNumCreatedRows").val() > 1) { $("#btnRemoveRow").prop("disabled", false); } // END if return false; }); $("#btnRemoveRow").click(function () { if ($("#txtNumCreatedRows").val() > 1) { $('table#tblGrid tr#Row'+$("#txtNumCreatedRows").val()).remove(); updateNumCreatedRows("txtNumCreatedRows", -1); if ($("#txtNumCreatedRows").val() <= 1) { $("#btnRemoveRow").prop("disabled", true); } // END if } // END if return false; }); }); function changeSignatureChk() { if ( $("#chkSignatureChk1").prop("checked") && $("#chkSignatureChk2").prop("checked") ) { $("#txtSignatureBox").prop("readonly", false); $("#txtSignatureBox").focus(); } else { $("#txtSignatureBox").prop("readonly", true); $("#txtSignatureBox").val(""); } // END if return false; } // END function changeSignatureChk() function addServiceCatRow() { iRowNum = $("#txtNumCreatedRows").val(); strReturn = ""; strReturn += "\n"; strReturn += ""+getFormLabelsJS("slctServiceCategory"+iRowNum, iRowNum+") "+"Service Category")+getSelectMenuArrayJS("slctServiceCategory"+iRowNum, "cssServiceCategory", "", "")+"

\n"; strReturn += getFormLabelsJS("txtaDescription"+iRowNum, iRowNum+") "+"Category Description")+getFormTextArea("txtaDescription"+iRowNum, "50||4", "cssDescription", "", "2000", "", false)+"\n"; strReturn += "\n"; $(strReturn).fadeIn("slow", "swing").appendTo('table#tblGrid'); setSelectOptions("slctServiceCategory"+iRowNum, "servicecat_json.php", "F3", ""); return false; } // END function addServiceCatRow()