Check "checkbox" status.

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
A Bindi
Veteran Member
Posts: 51
Joined: 2018-01-04 18:45

Check "checkbox" status.

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 ? :roll:

ALex.

User avatar
zibrahim
Veteran Member
Posts: 137
Joined: 2020-01-28 18:30
Location: Malaysia

Re: Check "checkbox" status.

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 24.10.1579, MacOS 14.3.1 Windows 11 on Parallels.

A Bindi
Veteran Member
Posts: 51
Joined: 2018-01-04 18:45

Re: Check "checkbox" status.

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.

Post Reply