Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Onchange client script to trigger alert if old value is not equal to new value

venkat101
Tera Guru

Hi,

I am trying to trigger an alert if user selects different choice apart from default choice. I set the default choice based on different field.

 

And below code works fine for that functionality if I dont add that validation of checking oldvalue is null. But, i want it to trigger if oldvalue is not null or empty and that is not i can not figure out.

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    //Type appropriate comment here, and begin script below
    if (oldValue.length > 0) {
        console.info("old value is null: " + oldValue);
        if (newValue !== oldValue) {
            alert("Note: Changing the choice is not recommended.");
        }
    }


}
5 REPLIES 5

@Community Alums  Nope like kb article, i still get oldValue or original value as "" even i though i select different choice.