2025-03-05 20:28:54 -06:00

45 lines
1.3 KiB
JavaScript

/**
* Add new role Modal JS
*/
'use strict';
document.addEventListener('DOMContentLoaded', function (e) {
(function () {
// add role form validation
FormValidation.formValidation(document.getElementById('addRoleForm'), {
fields: {
modalRoleName: {
validators: {
notEmpty: {
message: 'Please enter role name'
}
}
}
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap5: new FormValidation.plugins.Bootstrap5({
// Use this for enabling/changing valid/invalid class
// eleInvalidClass: '',
eleValidClass: '',
rowSelector: '.col-12'
}),
submitButton: new FormValidation.plugins.SubmitButton(),
// Submit the form when all fields are valid
// defaultSubmit: new FormValidation.plugins.DefaultSubmit(),
autoFocus: new FormValidation.plugins.AutoFocus()
}
});
// Select All checkbox click
const selectAll = document.querySelector('#selectAll'),
checkboxList = document.querySelectorAll('[type="checkbox"]');
selectAll.addEventListener('change', t => {
checkboxList.forEach(e => {
e.checked = t.target.checked;
});
});
})();
});