How can I make a input code in a page that makes you go to a next page?

I have a personal project that needs a mechanism that makes the user write down the password and when it’s right gets the user to the next page but when it’s wrong, reloads the page. Something like Do Not Believe In His Lies when it comes to the Enter Code mechanism. There’s a way I can do it on Wix?

Can’t I make a form like this to the user write the anwser and if it’s right go to the next page?

import wixLocation from ‘wix-location’;

$w.onReady(()=>{
	let myValue;
	$w('#input1').onChange(()=>{
		myValue = $w('#input1').value;
		console.log("My-Value: ", myValue);
	});
	
	$w('#myEnterCodeButtonIDhere').onClick(()>{
		wixLocation.to (myValue);
	});
});
  1. Add an input-element onto your page.
  2. Add the showed code above onto your page.
  3. Check all element-IDs.
  4. Type an web-address into the input and click onto your Enter-Code-Button.
  5. Also check the CONSOLE (this for you can deactivate…
//wixLocation.to (myValue);

Thanks, Ninja! First question, is my code right at all and second, how can I activate the Enter key input to it?

Some DEBUGGING was done…

import wixLocation from 'wix-location';

$w.onReady(()=>{
    let myValue;
    $w('#input1').onChange(()=>{
        myValue = $w('#input1').value;
        console.log("My-Value: ", myValue);
    });
    
    //About the ENTER-KEY.........
    $w('#input1').onKeyPress(()=>{
        if (event.key === "Enter") {
            console.log('ENTER-KEY was pressed!');
            wixLocation.to("https://"+myValue);
        }
        else {console.log('Another KEY was pressed!');}
    });    
    
    $w('#btnEnterCode').onClick(()=>{
        wixLocation.to("https://"+myValue);
    });
});

Type in… —> www.google.com and test it.