-
A Bindi
- Veteran Member
- Posts: 70
- Joined: 2018-01-04 18:45
Post
by A Bindi » 2022-09-26 15:51
Hello,
I have a table called "users" with a column "deactivated" (integer managed with a checkbox) and a column "date_deactivation" (date): I would like to check that the operator can't save a record checking "deactivated" without fill the "date_deactivation".
Can solve using hooks ?
ALex.
-
zibrahim
- Veteran Member
- Posts: 170
- Joined: 2020-01-28 18:30
- Location: Malaysia
Post
by zibrahim » 2022-09-27 11:44
Hi ALex
You can try this...(file : hooks/users-dv.js)
Code: Select all
// pop up modal alert when checkbox checked without date
$j('#deactivated').on('change', function () {
var dateVal = $j('#date_deactivation').val();
var activeSts = $j(this).prop('checked');
if (activeSts && !dateVal) {
modal_window({
message: '<div class="alert alert-danger">' + 'Please enter a date first' + '</div>',
title: 'Error !',
close: function () {
$j("#deactivated").prop("checked", false);
$j("#date_deactivation").focus();
$j("#date_deactivation").parents('.form-group').addClass('has-error');
},
});
}
});
Hope this works.
Zala.
Appgini 25.12, MacOS 15.5 Windows 11 on Parallels.
-
A Bindi
- Veteran Member
- Posts: 70
- Joined: 2018-01-04 18:45
Post
by A Bindi » 2022-09-30 08:41
Thank you zibrahim, great !
I will test immediately you JS and I’ll tell you.
ALex.