- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2017 07:47 AM
I currently have a select box and for the default value I have it as "-- Please Select --" but I also need this field to be mandatory field. When testing the red asterisk is there but if the field is left blank and the person submits the form anyway it still allows them to submit without filling in the mandatory fields.
Can someone point me in the right direction on how to fix this issue?
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2017 10:53 AM
Hey Craig,
you can add an onSubmit client script:
function onSubmit() {
//Type appropriate comment here, and begin script below
var v = g_form.getValue('select');//the name of your field
if(v == '-- Please Select --') {
alert('You must choose an option in the select field');
return false;
}
}
NOTE -
In place of "--Please Select --" put the value of that choice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2017 08:43 AM
Is the "-- Please Select --" your value, inserted manually? If it is, you can add an onSubmit client script:
function onSubmit() {
//Type appropriate comment here, and begin script below
var v = g_form.getValue('select');//the name of your field
if(v == '-- Please Select --') {//the value of the field
alert('You must choose an option in the select field');
return false;
}
}
harel
Edit: if this is a catalog item, then use a Catalog Client Script, not a client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2017 09:21 AM
Thank you for the quick response. After i inserted the script as a new client script i am still getting the same result.
During testing, if the field is left blank and the user submits, very quickly the blank field gets highlighted in a red box but proceeds to let the user submit the request anyway
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2017 12:19 PM
hi Craig,
What is the name of your field?
Note that I wrote:
var v = g_form.getValue('select');//the name of your field
In my example, the field's name was "select". In yours, it can be "type_of_request" - according to the screenshot you posted.
And one more thing:
What is the VALUE of the choice? The field has both a value and a display for the value - what's being shown to the user. In my example, both of them were '--Please Select--' but in your case they might be different.
The code I gave you works for sure, as I created it in my own instance.
If you are not clear on what to do, can you please share:
1. your code
2. a screenshot of your field
3. a screenshot of the --Please Select-- field
harel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2017 12:41 PM
Thank you for taking the time to troubleshoot. Please see below.
Code:
function onSubmit() {
//Type appropriate comment here, and begin script below
var v = g_form.getValue('Type of Request');//the name of your field
if(v == 'null') {//the value of the field
alert('You must choose an option in the select field');
return false;
}
}
Screenshot 1:
Screenshot 2:
Thank you,
Craig Zeleznick