Hi,
How do i prevent a submit button to be pressed unless it meets the minimum required quantity?
For example: Lets say the Hospital has a MOQ (minimum order quantity) and before the order can be placed for all the items the conditional logic (either in the SQL or not sure where) needs to check if it meets the MOQ of the hospital before it can be successful submitted?
Thanks for the help
Kind Regards,
Richard
How to have a MOQ conditional logic?
Re: How to have a MOQ conditional logic?
Hi,
you can add an additional hidden field to your form (unless you have it as e.g. readonly information) for the MOQ.
Then you register for the SAVE request and check if the MOQ is reached, if not you do not save the record with an adequate message to the user.
Note that you also need to check on the server-side as a client check may not be sufficient.
Hope that gives you a starting point.
you can add an additional hidden field to your form (unless you have it as e.g. readonly information) for the MOQ.
Then you register for the SAVE request and check if the MOQ is reached, if not you do not save the record with an adequate message to the user.
Note that you also need to check on the server-side as a client check may not be sufficient.
Hope that gives you a starting point.
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: How to have a MOQ conditional logic?
Thanks pböttcher
Do you have example code for me just to help to get started in the right direction please?
Do you have example code for me just to help to get started in the right direction please?
Re: How to have a MOQ conditional logic?
There are many ways to solve this. Here is just one example as a starting point.
Another solution would be hooking into change event of form, do your custom validation, perhaps disable #update (or #insert) button, show notifications or a combination of both. pböttcher is completely right: Never trust user input. You will need additional serverside validation for example in before_update hook.
Code: Select all
// file: hooks/TABLENAME-dv.js
function myCustomValidation() {
// check your conditions here
// do alerts or whatever you want to indicate
alert("no!");
// return false if you want to cancel update
return false;
}
jQuery("#update").on("click", function() {
return myCustomValidation();
});
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools