- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 06:24 AM - edited 03-20-2024 06:29 AM
Hi All,
I have created a field called "text" as a yes/no kind of variable so, when user selects the text as yes then we i have through an error meassge.
i have created like this onChange client script field as text
its not working as expected can someone help me here ..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 07:15 AM
Please validate the backend name of your choices inside dictionary of 'text' field. I am assuming Yes as true and no as false. Below is the script:
function onChangeText() {
var output = g_form.getValue('text');
if (output == 'true') {
g_form.addErrorMessage('Error message: You selected "Yes" for the text field.');
} else {
g_form.clearMessages(); // Clear any existing error messages
}
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 02:54 AM
Form does'nt get submitted for onchage client script, Try using on submit client script.
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 06:49 AM - edited 03-20-2024 06:49 AM
Hi @Naresh43 ,
if your field is yes/no then the backend value is specify a value of 0 (false) or 1 (true). So if it is on onchange client script on the same variable you can directly use newValue to get the value of selected variable. other than you can try the following code:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 06:56 AM
Hi @Naresh43 ,
Please clear the variable value after the addinfomessage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 06:59 AM
Hi @Naresh43
As per your script, it will display only error message. But, if you want to restrict form submission then write On submit client script.
Please Mark this Helpful and Accepted Solution if it solves your issue.
Thanks & Regards,
Shikha Tyagi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 07:15 AM
Please validate the backend name of your choices inside dictionary of 'text' field. I am assuming Yes as true and no as false. Below is the script:
function onChangeText() {
var output = g_form.getValue('text');
if (output == 'true') {
g_form.addErrorMessage('Error message: You selected "Yes" for the text field.');
} else {
g_form.clearMessages(); // Clear any existing error messages
}
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 07:39 AM
Hello @Maddysunil
like i have the above code now its throwing an error but if try to submit the form its submiting after that error also .
can you hlep me on this