Validate password before form submitting

Im trying to create a custom sign up lightbox for new members to sign up.
Everything works fine but the problem is that the form still gets submitted even when the password is invalid. in fact, all input fields has a field in the database except password of course thats why password is not taken in consideration when hitting submit.
Any idea how to solve this?
Thanks in Advance.

Thats how the code looks like:

import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
$w.onReady( function () {
let email = $w(‘#emailInput’).value
let password = $w(‘#passwordInput’).value
let firstName = $w(‘#firstName’).value
let lastName = $w(‘#lastName’).value
let phone = $w(‘#phone’).value
let adress = $w(‘#address’).value

const validateEmail = (otherEmailElementId) => (value, reject) => {
let otherEmailElement = $w(otherEmailElementId);
if (value === otherEmailElement.value) {
otherEmailElement.validity.valid = true ;
return ;
console.log(“Email and Confirm Your Email fields do not match”);
otherEmailElement.validity.valid = false ;
reject(“Email and Confirm Email fields do not match”);


const validatePassword = (otherPasswordElementId) => (value, reject) => {
let otherPasswordElement = $w(otherPasswordElementId);
if (value === otherPasswordElement.value) {
otherPasswordElement.validity.valid = true ;
return ;
console.log(“Password and Confirm Your Password fields do not match”);
otherPasswordElement.validity.valid = false ;
reject(“Password and Confirm Password fields do not match”);


$w(“#PaidMembersDB”).onBeforeSave((event) => {
if (!($w(‘#firstName’).valid && $w(‘#lastName’).valid && $w(‘#emailInput’).valid)) {
if (!$w(‘#firstName’).valid || !$w(‘#lastName’).valid)
if (!$w(‘#emailInput’).valid) {
if (!$w(‘#emailInput’).value)
else if ($w(‘#emailInput’).value !== $w(“#emailConfirmInput”).value) {
if (!$w(‘#passwordInput’).valid) {
if (!$w(‘#passwordInput’).value)
else if ($w(‘#passwordInput’).value !== $w(“#passwordConfirmInput”).value) {
export function firstName_change(event) {
export function lastName_change(event) {
export function emailInput_change(event) {
export function passwordInput_change(event) {

There is no field for password as nobody has access to site members passwords. This is done for security and safety reasons and you should never set up a dataset on your site to store users passwords either.

You are using the Wix example here and it does not validate the password entered by the user.

However, there are previous forum posts too that will get around this.

Hi, thanks for your reply, I read all the posts in the forum that discuss this subject but couldn’t get it to work. As I said I know that its not safe to keep the passwords in the database that why the password input field stays disconected and when Im clicking submit the form is being submited even thogh the password is not confirmed yet.

You should use the solution Anders describes here : . It would show you how it´s done.

One example of this is that I´m currently running with is:

First we store the 1st password:

export function Input_Change(event) {
// Code that runs when first password input has been entered
let password1 = $w('#input1).value;

Then on the “confirm password” we do the following:

export function Input2_Change(event) {
password2 = $w(‘#dinput2’).value;
if (password1===password2) {
$w(‘#button3’).enable(); /// Enables a button that allows the user to create account
$w(‘#button3’).label= “Create account”

} else { $w(‘#button3’).label = “Oppsies, your passwords does not match. Please try again”

Please let me know if you need more info :slight_smile:

Thanks for your reply, I couldn’t get it to work unfortunately…