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() } } );
![](https://static.wixstatic.com/media/a27d24_7adb2065a5f84023919f8dbf17e705c9~mv2.png/v1/fill/w_454,h_511,al_c,q_85,enc_auto/a27d24_7adb2065a5f84023919f8dbf17e705c9~mv2.png)
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.
The page has many errors, because the checkInputValues() function should not be inside of the button1_click() function.
@Yisrael okay I am not sure how to post the editor URL of my site
https://editor.wix.com/html/editor/web/renderer/edit/9041d559-2c26-4cdf-95fe-5c45df017416?metaSiteId=95ff8373-0b67-4e6d-b51e-f9e1d5a68b44&editorSessionId=5ab30fc2-efae-469b-a90f-117f707138df&referralInfo=my+sites
will this work? The page is called AC Brave.
Thank you again!
Thank you Yisrael,
I tried the code and it worked, but if you click twice on the code It will just go to the next page. Is that a limit that wix has?
thank you again for your help, I really appreciate it !