- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2019 04:34 AM
OnSubmit client script.
Variable is select box type. ( choices are 1. Select, yes, no) so I want user should select choice, form should not get submitted if choice value is Select or empty.
g_form.show error not working.
Thanks
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2019 04:41 AM
in the onsubmit client script, write like this.
//Update the field names and values correctly as per your code.
if(g_form.getValue("choice_field") == "select" || g_form.getValue("choice_field") == '') {
g_form.addErrorMessage("please select the choice")
return false;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2019 04:41 AM
in the onsubmit client script, write like this.
//Update the field names and values correctly as per your code.
if(g_form.getValue("choice_field") == "select" || g_form.getValue("choice_field") == '') {
g_form.addErrorMessage("please select the choice")
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2019 04:41 AM
Hi Sneha,
what is your exact code? can you post it here
it should be simple
function onSubmit(){
if(g_form.getValue('<column>') == ''){
return false;
}
}
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader