Files
votervue/js/addHistoryCode.js
T

75 lines
1.7 KiB
JavaScript
Raw Normal View History

2026-07-03 15:46:56 -04:00
// ================
// Add History Code
// ================
$(document).ready(function () {
var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}");
// -----------
// Input Masks
// -----------
$('#historycode_code').inputmask({
regex: "[A-Za-z]*"
});
// -----------
// Save Button
// -----------
$(".btnSave").on("click", function (e) {
e.preventDefault();
$("#addHistoryCode").submit();
});
// --------------
// Cancel Button.
// --------------
$(".btnCancel").on("click", function () {
formSubmit({action: $sessionStorage.addHistoryCode});
});
// ---------------
// Validate Inputs
// ---------------
$("#addHistoryCode").submit(function (e) {
var historycode_code = $("#historycode_code"),
historycode_description = $("#historycode_description");
clearInputErrors();
if (isBlank(historycode_code)) {
createInputError(historycode_code, "Code is required");
return false;
}
if (isBlank(historycode_description)) {
createInputError(historycode_description, "Description is required");
return false;
}
e.preventDefault();
$.post("./", $(this).serialize())
.done(function () {
$sessionStorage.action = $sessionStorage.addHistoryCode || "";
$sessionStorage.toast = "History Code was Added";
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
formSubmit($sessionStorage);
});
});
});