Validate an input with the Value of a Read only input

Hello,

Can anyone help me with a code for validating the input of a TEXT INPUT with the VALUE of another TEXT INPUT that is in Read only mode. See Image below.

User must enter the exactly the same text as shown in the Read only input or they get an error message.

Thanks
William

Hi William!

It should be a pretty simple code that compares the two strings to each other.
Its gonna look something like this:

export function button1_click(event, $w) {
 
 let key = $w('#key2Repeat').text;
 let inputToCheck = $w('#userInput').value;
 
 if (compare(key, inputToCheck)) {
      //message on success 
    } else {
          //message on failure
    }
}

function compare(string1, string2) {
 if (string1 === string2) {
    return true;
    } return false;
}

Hope it helps!
Doron. :slight_smile: