I want a script to display message based on the choice selected.

taahamushtaq
Tera Contributor

In my field, I want to display field message based on the choice selected. If the choice is changing then the message should also change.

2 REPLIES 2

Brian Lancaster
Tera Sage

OnChange client script with either g_form.showFieldMsg('field','message','info') or g_form.addInfoMessage('message'). The first one displays the message under the field and the second one displays the message at the top of the screen. The first step in your script should be the hide the messages so it clears it if a section changes. 

g_form.hideFieldMsg('field') or g_form.clearMessages().

Personally I like to use the show and hide field massage as it will appear were the user is looking.

Paul Curwen
Giga Sage

Write a onChange() Client script on your field. Example:

 

Note: replace yourfieldname with the name of your field where you want to show the filed message

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

    if (isLoading || newValue === '') {
         hideFieldMsg('yourfieldname') //hide field messages if nothing to report
         return;
    }

g_form.showFieldMsg('yourfieldname','Thanks for changing me','info);

}

 

***If Correct/Helpful please take time mark as Correct/Helpful. It is much appreciated.***

Regards

Paul