Trying to validate password, without success

Im trying to validate password, so the new member have to put in the same password twice.

But now with this code the member still can put in two different password and submit. The page will register the “email” and “password” without validate that the passwords are the same in “password” and “password2”

Don’t understand why tho,
Any help Is helpful :slight_smile:

You need to move your wixUsers.register section of your code. It should be placed just after you console.log(“Dem matchar”). else should be the last bit of code on your page…

U help me last time, your the man! Tanx again. But I get this annoying little “error”…

@alexfors

Can you copy and paste your code here instead of the picture and i will modify it to what it should be

@mikemoynihan99 Sure thing!

import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;

$w.onReady( function (){
$w(‘#registerNow’).onClick( function (){
let email = $w(‘#mail1’).value;
let password = $w(‘#losen1’).value;
let password2 = $w(‘#losen2’).value;

if (password === password2) {
console.log(“Dem matchar!”);
} else {
console.log(“Dem matchar inte!”);
wixUsers.register(email,password)
then(()=>{
wixLocation.to(‘/testing’);
})
})
})

@alexfors

import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;

$w.onReady( function (){
$w(‘#registerNow’).onClick( function (){
let email = $w(‘#mail1’).value;
let password = $w(‘#losen1’).value;
let password2 = $w(‘#losen2’).value;

if (password === password2) {

//if password matches we console.log success message and register the user

console.log(“Dem matchar!”);

wixUsers.register(email,password)
.then(()=>{
wixLocation.to(‘/testing’);
})

}
//if password does not match console.log error message
else {
console.log(“Dem matchar inte!”);

    } 
}) 
})

@mikemoynihan99 It worked, you’re the best! Note: the message “Dem matcher inte” - translated They don’t match! didn’t pop up when it was two different, but I can live without it. It just didn’t register the member