Onchange client script not working

sunil maddheshi
Tera Guru

Hi guys

I have a simple onchange client script on description field on incident table

 

My requirement is if user input is "//H$\\DB_Backup" then it should be accepted else not accepted

 

Below is script but everytime getting not accepted even for exactly same value

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

 

if (newValue == "//H$\\DB_Backup")
alert("accepted");
else
alert("not accepted");
}

 

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

The backslash (\) is an escape character, so in the script you need to escape each one, if that makes any sense.

if (newValue == "//H$\\\\DB_Backup")

View solution in original post

2 REPLIES 2

Brad Bowman
Kilo Patron
Kilo Patron

The backslash (\) is an escape character, so in the script you need to escape each one, if that makes any sense.

if (newValue == "//H$\\\\DB_Backup")

Samiksha Gunjat
Kilo Guru

Hi @sunil maddheshi,

Can you try updating the below scripts.

 

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

    alert("Trimmed Value: " + newValue);

    if (newValue.includes("//") && newValue.includes("_")) {
        alert("Accepted");
    } else {
        alert("Not Accepted");
    }
}

Please mark this comment as Correct Answer/Helpful if it helped you. 

 

Regards,

Samiksha Gunjate