- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2018 12:21 PM
I have a true/false field on a form that I want to make mandatory. After reading through some posts, I came across this one, which recommended writing the following onSubmit client script:
function onSubmit() {
var value = g_form.getValue('searched_resources');
if(!value){
alert('Please check the checkbox before submitting a new HR Request');
return false;
}
}
I have UI Type set to All, but I can still submit this form without checking the checkbox. What am i missing? Thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2018 01:02 PM
Can you try something as below and it will work
function onSubmit() {
//Type appropriate comment here, and begin script below SpaceIsThePlace
if (g_form.getValue('searched_resources')=='false') {
alert('Please check the checkbox before submitting a new HR Request');
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2018 01:35 PM
ahh so close, thanks!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2018 01:30 PM
It should check for both null and false. So the script should be
function onSubmit() {
//Type appropriate comment here, and begin script below SpaceIsThePlace
if (g_form.getValue('searched_resources')=='false' || g_form.getValue('searched_resources')=='') {
alert('Please check the checkbox before submitting a new HR Request');
return false;
}
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2018 12:56 PM
Make the field mandatory so it needs a value
Then have an onChange client script so if the new value is not true you set the value to
if (newValue != true) {
g_form.setValue(<variable>,'');
}
The check makes the variable blank instead of clearing and then the mandatory is enforced