How to prevent changing values in a field from onChange client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2019 03:02 PM
I have a requirement to prevent changing values of certain field from onChange client script.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
if ( newValue === '' ) {
var ans = confirm("Confirmation message.");
if (ans == true){
g_form.setValue('comments', " ");
}
else if (ans == false){
// Need to prevent changing values here
return;
}
}
}
What are the possible ways that I can prevent changing values of the field based on condition?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2022 08:56 PM
Hi,
I have a similar issue, I want to prevent changing the variable value to another if the condition is failed. Unable to use oldValue on onchange client script to set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2022 12:48 AM
Hi Sathish,
Explore g_form.addOption() and g_form.removeOption methods. It will resolve your issue. Based on conditions you can add or remove options from a field so user will have only those options to select which you want them to select.
Please mark my answer as correct, if it helped you resolve your query