- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2022 05:20 AM
Hello Everyone,
I need your help, I need to access the value of the drop-down menu which is available of form, and if the user select ABC from drop-down menu than it will compare the location and if user select XYZ then it will not.
my code:
var ch = g_form.getValue('type_of');
if (ch == "ABC"){
if (g_form.getValue('loc1') == g_form.getValue('loc2')){
g_form.addErrorMessage('Location can't be same');
}retrun false;
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2022 06:15 AM
Hi,
Please use below script and see what value you get using g_form.getValue().
var ch = g_form.getValue('type_of');
alert('You have selected : '+ch); / this will help you to get background value of Type variable.
if (ch == "abc") { //update this condition with value of choice ()
if (g_form.getValue('loc1') == g_form.getValue('loc2')) {
g_form.addErrorMessage('Location can\'t be same ');
return false;
}
}
You might be using Label in If condition instead use value of choice 'ABC' for field type_of.
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2022 05:27 AM
Hi,
Can you tell me the issue you are facing with this code?
I see few issues in this code.
1) Spelling mistake on return command
2) Return command be inside the if block.
3) You should add escape sequence before using single quotes inside a string
Hope this is written in on submit client script. So the code should be below:
function onSubmit() {
var ch = g_form.getValue('type_of');
if (ch == "ABC") {
if (g_form.getValue('loc1') == g_form.getValue('loc2')) {
g_form.addErrorMessage('Location can\'t be same ');
return false;
}
}
}
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2022 05:33 AM
Hello
As I mentioned above if the user selects ABC from the drop-down menu, then my if block should be triggered else not.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2022 05:37 AM
Can you please share what are the choices and variable names?
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2022 05:47 AM
Drop down menu have 2 choice ABC & XYZ
var ch = g_form.getValue('type_of');
if (ch == "ABC"){
if(g_form.getValue('loc1') == g_form.getValue('loc2')){
g_form.addErroressage('Location cannot be same')
return false;}
}