Created a login page, but having trouble matching email and confirm password. HELP!!

Hello anukrant,

perhaps this example could help you…
https://russian-dima.wixsite.com/meinewebsite/user-infos

i dont have much coding experience, but with common sense tried updating this on wix code. can you help me rectify it.

This is the Signup Page. Password and Confirm Password field key is 'pwd' and 'Cnfpwd'


$w.onReady(function () {

const validatePass = (otherPassElementId) => (value, reject) => {
let otherPassElement = $w(otherPassElementId);
if (value === otherPassElement.value) {
//otherEmailElement.validity.valid = true;
otherPassElement.resetValidityIndication();
return;
}
console.log(“Password fields do not match”);
otherPassElement.validity.valid = false;
otherPassElement.updateValidityIndication();
reject(“Password fields do not match”);
};
$w(“#Cnfpwd”).onCustomValidation(validatePass(“#pwd”));
$w(“#pwd”).onCustomValidation(validateEmail(“#Cnfpwd”));

$w('#dataset1').onBeforeSave(() => {

if (!($w(‘#firstName’).valid && $w(‘#lastName’).valid && $w(‘#email’).valid))
{
let validationMessage = ‘’;

if (!$w(‘#firstName’).valid || !$w(‘#lastName’).valid)
validationMessage += ‘Please enter your name\n’;

if (!$w(‘#pwd’).valid) {
if (!$w(‘#pwd’).value)
validationMessage += ‘Please enter a valid password\n’;
else if ($w(‘#pwd’).value !== $w(“#Cnfpwd”).value) {
validationMessage += ‘Email and Confirm Email fields do not match\n’;
}
}

        $w('#validationMessages').text = validationMessage;
        $w('#validationMessages').expand();
    }

else
$w(‘#validationMessages’).collapse();
});

});

Well, ok i am a little bit confused :grin::roll_eyes:
In your post-header you mention the “Log-In”, but what i see on the pic is a “REGISTRATION”.

So what you try to do now?
a) Create a custom Log-In-page?
b) Create a custom registration-page?

And do you use your own database for it, or the “PrivateMembersData” ???

If You want to realize a registration-page, this post could help you…
https://www.wix.com/corvid/forum/tips-tutorials-examples/custom-member-registration

I am trying to create a registration page. i have basically created a database with ‘Login’ name. Have done correction to the code already now, with some common sense, but the message is not getting published on the site. i am trying to figure out., but let me know if you can add some inputs.
this is the final code

$w.onReady(function () {

 const validatePass = (otherPassElementId) => (value, reject) => {
 let otherPassElement = $w(otherPassElementId);
 if (value === otherPassElement.value) {
 //otherEmailElement.validity.valid = true;
            otherPassElement.resetValidityIndication();
 return;
        } 
        console.log("Password fields do not match");
        otherPassElement.validity.valid = false;
        otherPassElement.updateValidityIndication();
        reject("Password fields do not match");
    };
    $w("#Password2").onCustomValidation(validatePass("#Password1"));
    $w("#Password1").onCustomValidation(validatePass("#Password2"));
 
    $w('#dataset1').onBeforeSave(() => {
 if (!($w('#firstName').valid && $w('#lastName').valid && $w('#email').valid)) 
        {
 let validationMessage = '';

 if (!$w('#firstName').valid || !$w('#lastName').valid)
                validationMessage += 'Please enter your name\n';

 if (!$w('#Password1').valid) {
 if (!$w('#Password1').value)
                    validationMessage += 'Please enter a valid password\n';
 else if ($w('#Password1').value !== $w("#Password2").value) {
                    validationMessage += 'Passwords fields do not match\n';
                }   
            }

            $w('#publishtext').text = validationMessage;
            $w('#publishtext').expand();
        }
 else
            $w('#publishtext').collapse();
    });
 
});

This is an example how i would solve this problem, by using the “PrivateMembersData” of Wix.

import wixUsers from 'wix-users';

$w.onReady(function () {   })

export function BTNregistration_click(event) {registration()}

function registration (parameter) {console.log("Registration done!")
 let email =     $w('#INPUT1').value
 let firstName = $w('#INPUT2').value
 let lastName =  $w('#INPUT3').value
 let phone =     $w('#INPUT4').value
 let nickname =  $w('#INPUT5').value
 let password =  $w('#INPUT6').value

    wixUsers.register(email, password, {
        contactInfo: {
 "firstName": firstName,
 "lastName": lastName,
 "phone": phone,
 "nickname": nickname
        }
    } )
    .then( (result) => {
 let resultStatus = result.status;
    } );
}

and here the updated example…
https://russian-dima.wixsite.com/meinewebsite/user-infos
Take a look at the registration option!

Perhaps this can help you too…

thanks a lot ‘russian-dima’ for your help. i was able to manage output on my registration page.

Do you wanna show your result?

sure. here is the code. 
$w.onReady(function () {
        $w("#Signupbutton").onClick( () => {

 const validatePass = (otherPassElementId) => (value, reject) => {
 let otherPassElement = $w(otherPassElementId);
 if (value === otherPassElement.value) {
 //otherEmailElement.validity.valid = true;
            otherPassElement.resetValidityIndication();
 return;
        } 
        console.log("Password fields do not match");
        otherPassElement.validity.valid = false;
        otherPassElement.updateValidityIndication();
        reject("Password fields do not match");
    };
    $w("#Password2").onCustomValidation(validatePass("#Password1"));
    $w("#Password1").onCustomValidation(validatePass("#Password2"));
 
    $w('#Loginsignup').onBeforeSave(() => {
 if (!($w('#firstName').valid && $w('#lastName').valid && $w('#email').valid)) 
        {
 let validationMessage = '';

 if (!$w('#firstName').value || !$w('#lastName').value)
                validationMessage += 'Please enter your name\n';
 
 if (!$w('#email').value)
                validationMessage += 'Please enter your email\n';

 if (!$w('#Password1').valid) {
 if (!$w('#Password1').value)
                    validationMessage += 'Please enter a valid password\n';
 else if ($w('#Password1').value !== $w("#Password2").value) {
                    validationMessage += 'Passwords fields do not match\n';
                }   
            }

            $w('#publishtext').text = validationMessage;
            $w('#publishtext').expand();
        }
 else
            $w('#publishtext').collapse();
    });
        });
    });

Thx for sharing and goog luck with your site-project.

Just note that the code you have originally posted up is simply the code from the Wix exmaple for validating user inputs on a form before a save.
https://www.wix.com/corvid/example/custom-validations

$w.onReady(function () {

	const validateEmail = (otherEmailElementId) => (value, reject) => {
		let otherEmailElement = $w(otherEmailElementId);
	 	if (value === otherEmailElement.value) {
  			otherEmailElement.validity.valid = true;
  			otherEmailElement.resetValidityIndication();
	    	return;
	  	} 
	  	console.log("Email and Confirm Your Email fields do not match");
	  	otherEmailElement.validity.valid = false;
	  	otherEmailElement.updateValidityIndication();
	  	reject("Email and Confirm Email fields do not match");
	};
	$w("#emailConfirmInput").onCustomValidation(validateEmail("#emailInput"));
	$w("#emailInput").onCustomValidation(validateEmail("#emailConfirmInput"));
	
	$w('#dataset1').onBeforeSave(() => {
		if (!($w('#firstName').valid && $w('#lastName').valid && $w('#emailInput').valid &&
			  $w('#phone').valid && $w('#address').valid)) {

			let validationMessage = '';

			if (!$w('#firstName').valid || !$w('#lastName').valid)
				validationMessage += 'Please enter your name\n';

			if (!$w('#emailInput').valid) {
				if (!$w('#emailInput').value)
					validationMessage += 'Please enter an email address\n';
				else if ($w('#emailInput').value !== $w("#emailConfirmInput").value) {
					validationMessage += 'Email and Confirm Email fields do not match\n';
				}	
			}

			if (!$w('#phone').valid)
				validationMessage += 'Please enter a valid phone number\n';

			if (!$w('#address').valid)
				validationMessage += 'Please enter an address\n';

			$w('#validationMessages').text = validationMessage;
			$w('#validationMessages').expand();
		}
		else
			$w('#validationMessages').collapse();
	});
	
});

You can read more about validations here.

The form itself will work as it is, you had just duplicated the password field instead of the email field, so you would only need to change your code to suit and it would have been fine.

It also looks like you are using a Custom member signup form and not an actual Corvid signup form, so the registration is still done by Wix for you in the background.

You have three choices, Default, Custom and Corvid.

As for your issue, if you where doing this on a Corvid member signup form, then you would have needed to included the register() function from the Wix users API in your code for it to actually register a user with the user inputs that you have on that form.

Your signup button would need to register the user using the register() function, either through Wix Users API or Wix Users Backend API.
https://www.wix.com/corvid/reference/wix-users.html#register
https://www.wix.com/corvid/reference/wix-users-backend.html#register

Register a user as a site member with registration options

import wixUsers from 'wix-users';

// ...

let email = // the user's email addresses
let password = // the user's password
let firstName = // the user's first name
let lastName = // the user's last name
let phone =  // the user's phone number
let nickname = // the user's nickname

wixUsers.register(email, password, {
    contactInfo: {
        "firstName": firstName,
        "lastName": lastName,
        "phone": phone,
        "nickname": nickname
    }
  } )
  .then( (result) => {
    let resultStatus = result.status;
  } );

If you wanted to make your own Corvid lightbox for signup instead of using the Custom option and include the validation on the inputs, then check out Nayeli (Code Queen) example here which would be a great option for you to work with.
Wix Custom Registration to Check Existing User and Input Validation
https://www.totallycodable.com/wix/corvid/corvid-registration-code-check-existing-user-and-input-validation

Finally, please don’t say that you are saving all those user inputs into that Login dataset as you should NEVER be storing users passwords in any database on your site. That should all be done through Wix.

Plus, check out this one too, although this is not for a beginner :wink:
https://www.wix.com/corvid/example/members-area