- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2016 05:56 AM
I have a checkbox that says "check this box if you agree to the policy terms...". I made the variable "mandatory", but I can still click "order now" even when the checkbox is not checked. How can I make it so you can only "order now" after the checkbox has been clicked?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
-
Team Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2016 06:58 AM
getValue() return the value as string. Try this
function onSubmit() {
//Type appropriate comment here, and begin script below SpaceIsThePlace
if (g_form.getValue('PolicyAgreement')=='false') {
g_form.showFieldMsg('PolicyAgreement', 'You must check the Policy Agreement checkbox', 'error');
return false;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2016 06:00 AM
Hi Michael,
Checkboxes ALWAYS contain a value (true or false). Mandatory means you cannot submit it if the field is null/empty. That's not the case with true/false. So you have two options.
Option a) Change it to a choice list with None, Yes, No and make it mandatory
Option b) Create an onSubmit script that checks for a true value and aborts if not found. Something like below.
function onSubmit() {
if (!g_form.getValue('my_checkox')) {
g_form.showFieldMsg('my_checkbox', 'You must check this box', 'error');
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2016 06:50 AM
Running that script would be ideal, but I can't get it to work. I can still "Order Now" without checking the box.
In the catalog Item page, I create a new "Catalog Client Script". Applies to "A Catalog Item". Catalog item = "Mobile Device Reimbursement". Type = "onSubmit". Script:
function onSubmit() {
//Type appropriate comment here, and begin script below SpaceIsThePlace
if (!g_form.getValue('PolicyAgreement')) {
g_form.showFieldMsg('PolicyAgreement', 'You must check the Policy Agreement checkbox', 'error');
return false;
}
}
am I doing anything wrong?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2016 06:58 AM
getValue() return the value as string. Try this
function onSubmit() {
//Type appropriate comment here, and begin script below SpaceIsThePlace
if (g_form.getValue('PolicyAgreement')=='false') {
g_form.showFieldMsg('PolicyAgreement', 'You must check the Policy Agreement checkbox', 'error');
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2016 07:12 AM
That's the magic I was looking for! Thank ya!