
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2022 10:24 AM
Dear experts,
Is the following possible in one single onChange client script? I understand, we can have the onLoad as a separate client script.
Task 1 - Validate some values of a checkbox to be true or false on load of a form and apply logic.
Task 2 - proceed next into onChange validation and logic.
Example:
function onLoad()
{
//executes first
}
function onChange(parameters)
{
//executes next
}
Regards,
Anish
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2022 10:30 AM
function onChange(control, oldValue, newValue, isLoading, isTemplate) { //If the form is loading or the new value of the changing field is empty exit the script if (isLoading || newValue == '') {
/// Write your onload logic here
return; }
On change logic under it .
Mark correct and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2022 10:30 AM
function onChange(control, oldValue, newValue, isLoading, isTemplate) { //If the form is loading or the new value of the changing field is empty exit the script if (isLoading || newValue == '') {
/// Write your onload logic here
return; }
On change logic under it .
Mark correct and helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2022 10:42 AM
Use Case:
Agree, we are validating a logic while the form is loading, but what if the validation is to happen after the form has loaded and before the onChange is to be validated?
function onChange(control, oldValue, newValue, isLoading, isTemplate) { //If the form is loading or the new value of the changing field is empty exit the script
if (isLoading || newValue == '') {
return; }
You might propose:
if(isLoading)
{
//apply Logic;
if(g_form.getValue('field_name') == 'true')
//do this;
}
//Continue with onChange logic.
doesn't work!
Regards,
Anish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2022 10:46 AM
Hi Anish,
Try this.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
//If the form is loading or the new value of the changing field is empty exit the script
You might propose:
if(isLoading)
{
//apply Logic;
if(g_form.getValue('field_name') == 'true')
//do this;
}
if(!isLoading)
{
//Continue with onChange logic.
}
Regards,
Musab

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2022 11:32 AM
Hi Musab, thanks! but won't really make a difference,
since,
I am trying to make this part work:
if(isLoading)
{
//apply Logic;
if(g_form.getValue('field_name') == 'true')
//do this;
}
This one is already working:
//Continue with onChange logic.
So, doing a if(!isLoading) technically, doesn't make a difference.
I repeat, what is needed is:
- Logic to run after the form is loaded
- and before proceeding into the onChange logic.
Regards,
Anish