// ================ // Add Dropdowntype // ================ $(document).ready(function() { var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"); // ----------- // Save Button // ----------- $(".btnSave").on("click", function(e) { e.preventDefault(); $("#addDropdowntype").submit(); }); // -------------- // Cancel Button. // -------------- $(".btnCancel").on("click", function() { formSubmit({ action : $sessionStorage.addDropdowntype }); }); // --------------- // Validate Inputs // --------------- $("#addDropdowntype").submit( function(e) { var dropdowntype_name = $("#dropdowntype_name"), dropdowntype_title = $("#dropdowntype_title"), dropdowntype_table = $("#dropdowntype_table"), dropdowntype_column = $("#dropdowntype_column"); clearInputErrors(); dropdowntype_name.val(dropdowntype_name.val().replace(/\s+/g, " ").trim()); dropdowntype_title.val(dropdowntype_title.val().replace(/\s+/g, " ").trim()); dropdowntype_table.val(dropdowntype_table.val().replace(/\s+/g, " ").trim()); dropdowntype_column.val(dropdowntype_column.val().replace(/\s+/g, " ").trim()); if (isBlank(dropdowntype_name)) { createInputError(dropdowntype_name, "Name is required"); return false; } if (formPost({ action : "Dropdowns.dropdowntypeExists", dropdowntype_serial : 0, dropdowntype_name : dropdowntype_name.val() }) === true) { createInputError(dropdowntype_name, "Name already exists"); return false; } if (isBlank(dropdowntype_title)) { createInputError(dropdowntype_title, "Title is required"); return false; } if (formPost({ action : "Dropdowns.dropdowntypetitleExists", dropdowntype_serial : 0, dropdowntype_title : dropdowntype_title.val() }) === true) { createInputError(dropdowntype_title, "Title already exists"); return false; } if (isBlank(dropdowntype_table)) { createInputError(dropdowntype_table, "Table is required"); return false; } if (isBlank(dropdowntype_column)) { createInputError(dropdowntype_column, "Column is required"); return false; } e.preventDefault(); $.post("./", $(this).serialize()) .done(function() { $sessionStorage.action = $sessionStorage.addDropdowntype || ""; $sessionStorage.toast = "Dropdown Type was Added"; sessionStorage.setItem($application, JSON.stringify($sessionStorage)); formSubmit($sessionStorage); }); }); });