Hello,
I am new to coding and I have been trying to figure this out all day.
I am trying to have two text inputs match as a way to confirm that the user has submitted a matching email.
if the two text input are not matching, the button is disabled and an error shows on the inputs saying "the emails dont match"
I hope you understand what I mean, I have included my code and the image here below.
Please send help,
Nooh
$w.onReady(function () { let mail1 = $w("#input11").value; let mail2 = $w("#input15").value; if(!mail2 === mail1){ $w('#button1').disable() } else { $w('#button1').enable() } } );
Putting your code in the onReady() function means that it will only run one time - when the page is ready. I assume that your intention is the check the two values each time the fields are entered or modified. So, you want something like this:
$w.onReady(function () { $w(“#input11").onInput( (event) => { checkInputValues(); } ); $w(“#input15").onInput( (event) => { checkInputValues() } ); }); function checkInputValues() { let mail1 = $w("#input11").value; let mail2 = $w("#input15").value; if(mail2 === mail1) { $w('#button1').enable(); } else { $w('#button1').disable(); } }
The above code will compare the values of the two input fields as the user types in each field. #button1 will be enabled when both fields are identical.