Hi,
does anyone of you have an idea to disable the save button depending on a field value?
Thanks very much, Kai
Disable the save button depending on a field value
Re: Disable the save button depending on a field value
Hi,
can you be a bit more specific on what type of field/situation you want to disable the save button?
can you be a bit more specific on what type of field/situation you want to disable the save button?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Disable the save button depending on a field value
Thank you very much for your help. I need information that is a prerequisite for creating a data record. It's about German data protection.
E.g. a checkbox or a text field with yes / no. If the check box is not set or the field is set to "no" and initially the save button should be disabled. if the checkbox is set or the field is set to yes, it should be enabled and can then be saved.
A bit like a "data protection consent" checkbox on a email form.
I hope I described it correctly.
Thank you very much!
E.g. a checkbox or a text field with yes / no. If the check box is not set or the field is set to "no" and initially the save button should be disabled. if the checkbox is set or the field is set to yes, it should be enabled and can then be saved.
A bit like a "data protection consent" checkbox on a email form.
I hope I described it correctly.
Thank you very much!
Re: Disable the save button depending on a field value
Hi,
for a checkbox you can try
replace FIELDNAME with your fieldname for the checkbox. Also you should check at the beginning if the checkbox is already set and disable/enable the update botton accordingly.
If you are in the "insert" process for a record, use #insert instead of #update.
for a checkbox you can try
Code: Select all
$j('#FIELDNAME').on('change',function(e) {if ($j(this).is(':checked')) {$j('#update').attr('disabled',false) } else {$j('#update').attr('disabled','disabled')}})
If you are in the "insert" process for a record, use #insert instead of #update.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Disable the save button depending on a field value
Hi,
thank you very much
I try it next days.
Many greetings
thank you very much
I try it next days.
Many greetings
Re: Disable the save button depending on a field value
Hi,
i tried your code. Thank you very much again. Unfortunately I can't get it work. Is it correct that i put the code in the
tablename-dv.js in the hooks directory?
Thanks very much, Kai
i tried your code. Thank you very much again. Unfortunately I can't get it work. Is it correct that i put the code in the
tablename-dv.js in the hooks directory?
Thanks very much, Kai
Re: Disable the save button depending on a field value
Hi Kai,
yes it is correct. But without more information (or even better a sample) it is hard to help more.
yes it is correct. But without more information (or even better a sample) it is hard to help more.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Disable the save button depending on a field value
Hi,
sorry. You know, i´m not a coder
I tried
in (this is my employee table).
"consent" is the field name of my checkbox.
The checkbox is intended to confirm that the employee agrees to their data being saved. If the checkbox is not set, I want to prevent the data set from being saved. I would like to disable the save button if the checkbox is not set and enable it if it is set.
Thank you very much, Kai
sorry. You know, i´m not a coder
I tried
Code: Select all
$j('#consent').on('change',function(e) {if ($j(this).is(':checked')) {$j('#update').attr('disabled',false) } else {$j('#update').attr('disabled','disabled')}})
Code: Select all
/hooks/employees_de-dv.js
"consent" is the field name of my checkbox.
The checkbox is intended to confirm that the employee agrees to their data being saved. If the checkbox is not set, I want to prevent the data set from being saved. I would like to disable the save button if the checkbox is not set and enable it if it is set.
Thank you very much, Kai
Re: Disable the save button depending on a field value
I'm using this code to hide the button if group is not equal to Admins, place it in the /hooks/tablename.php
Inside the: function tablename_dv($selectedID, $memberInfo, &$html, &$args){
Inside the: function tablename_dv($selectedID, $memberInfo, &$html, &$args){
Code: Select all
if ($memberInfo["group"] != "Admins") {
$html .= '<script>$j('#update').parents('.btn-group-vertical').hide();</script>';
}
Re: Disable the save button depending on a field value
Thanks Alisson for the code.
Since the release of latest AG with the additional 'lock' icon on the right side of the "Save Changes" button, you may need to change the hide code to
instead of
hope this will help someone.
Stay safe
Since the release of latest AG with the additional 'lock' icon on the right side of the "Save Changes" button, you may need to change the hide code to
Code: Select all
$j('#update').parents('.btn-group-lg').hide();
Code: Select all
$j('#update').parents('.btn-group-vertical').hide();
Stay safe
Zala.
Appgini 24.10.1579, MacOS 14.3.1 Windows 11 on Parallels.
Appgini 24.10.1579, MacOS 14.3.1 Windows 11 on Parallels.