Hi there!
I have a custom registration page that I need help. I have First Name, Last Name, Email, and Password. I would like to require the First name, Email and password. I checked the required checkbox on the settings for the three. However, I tried it on the live website and it still let me register even without my first name.
Also, I have an error message I would love to show when a required field is missing/error. Is that on the correct line?
Additionally, the code works fine before but it won’t work just now . It seems Wix has problems with these code sometimes. It won’t register anymore. Please help!
My code is below:
import wixUsers from 'wix-users';
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';
$w.onReady(function () {
$w("#registerButton").onClick( (event) => {
let email = $w("#email").value;
let password = $w("#password").value;
let first = $w("#firstName").value;
let last = $w("#lastName").value;
wixUsers.register(email, password, {
contactInfo: {
"firstName": first,
"lastName": last,
}
} )
.then(()=>{
wixLocation.to('/home');
})
.catch( (err) => {
$w("#error").expand(); // You can delete this line if you are not going to add an error message. Use a regular text element set to 'collapse on load' from the Properties Panel.
} );
})
})