this.nameError = 'Name must be less than 100 characters';
this.nameValid = false;
} else if (!nameRegex.test(this.name.trim())) {
this.nameError = 'Name can only contain letters, spaces, hyphens, and apostrophes';
this.nameValid = false;
} else if (this.name.trim().split(' ').length < 2) {
this.nameError = 'Please enter your full name (first and last name)';
this.nameValid = false;
} else {
this.nameError = '';
this.nameValid = true;
// Clear server-side errors when client validation passes
if (this.$wire.errors.name) {
this.$wire.clearErrors('name');
}
}
},
validatePassword() {
if (!this.password) {
this.passwordError = '';
} else if (this.password.length < 8) {
this.passwordError = 'Password must be at least 8 characters for security';
} else if (this.password.length > 128) {
this.passwordError = 'Password must be less than 128 characters';
} else if (!this.hasUppercase) {
this.passwordError = 'Password must contain at least one uppercase letter';
} else if (!this.hasLowercase) {
this.passwordError = 'Password must contain at least one lowercase letter';
} else if (!this.hasNumber) {
this.passwordError = 'Password must contain at least one number';
} else if (/(.)\1{2,}/.test(this.password)) {
this.passwordError = 'Password cannot contain repeated characters';
} else if (this.password.includes(' ')) {
this.passwordError = 'Password cannot contain spaces';
} else if (this.password.toLowerCase().includes('password')) {
this.passwordError = 'Password cannot contain the word "password"';
} else if (this.password.toLowerCase().includes('123456')) {
this.passwordError = 'Password cannot contain sequential numbers';
} else {
this.passwordError = '';
// Clear server-side errors when client validation passes
if (this.$wire.errors.password) {
this.$wire.clearErrors('password');
}
}
},
// Password validation getters
get passwordLength() {
return this.password && this.password.length >= 8;
},
get hasUppercase() {
return this.password && /[A-Z]/.test(this.password);
},
get hasLowercase() {
return this.password && /[a-z]/.test(this.password);
},
get hasNumber() {
return this.password && /[0-9]/.test(this.password);
},
// Update password type for toggle
get passwordType() {
return this.showPasswordToggle ? 'text' : 'password';
},
// Referral code validation
checkReferralCode() {
this.validateReferralCode();
},
validateReferralCode() {
// Referral code is optional
if (!this.referralCode || this.referralCode.trim() === '') {
this.referralCodeError = '';
this.referralCodeValid = true;
return;
}
// Convert to uppercase
this.referralCode = this.referralCode.toUpperCase().trim();
// Validate format (alphanumeric, max 20 chars)
const codeRegex = /^[A-Z0-9]+$/;
if (this.referralCode.length < 3) {
this.referralCodeError = 'Referral code must be at least 3 characters';
this.referralCodeValid = false;
} else if (this.referralCode.length > 20) {
this.referralCodeError = 'Referral code must be less than 20 characters';
this.referralCodeValid = false;
} else if (!codeRegex.test(this.referralCode)) {
this.referralCodeError = 'Referral code can only contain letters and numbers';
this.referralCodeValid = false;
} else {
this.referralCodeError = '';
this.referralCodeValid = true;
// Clear server-side errors when client validation passes
if (this.$wire.errors.referral_code) {
this.$wire.clearErrors('referral_code');
}
}
}
}
});
this.nameError = 'Name must be less than 100 characters';
this.nameValid = false;
} else if (!nameRegex.test(this.name.trim())) {
this.nameError = 'Name can only contain letters, spaces, hyphens, and apostrophes';
this.nameValid = false;
} else if (this.name.trim().split(' ').length < 2) {
this.nameError = 'Please enter your full name (first and last name)';
this.nameValid = false;
} else {
this.nameError = '';
this.nameValid = true;
// Clear server-side errors when client validation passes
if (this.$wire.errors.name) {
this.$wire.clearErrors('name');
}
}
},
validatePassword() {
if (!this.password) {
this.passwordError = '';
} else if (this.password.length < 8) {
this.passwordError = 'Password must be at least 8 characters for security';
} else if (this.password.length > 128) {
this.passwordError = 'Password must be less than 128 characters';
} else if (!this.hasUppercase) {
this.passwordError = 'Password must contain at least one uppercase letter';
} else if (!this.hasLowercase) {
this.passwordError = 'Password must contain at least one lowercase letter';
} else if (!this.hasNumber) {
this.passwordError = 'Password must contain at least one number';
} else if (/(.)\1{2,}/.test(this.password)) {
this.passwordError = 'Password cannot contain repeated characters';
} else if (this.password.includes(' ')) {
this.passwordError = 'Password cannot contain spaces';
} else if (this.password.toLowerCase().includes('password')) {
this.passwordError = 'Password cannot contain the word "password"';
} else if (this.password.toLowerCase().includes('123456')) {
this.passwordError = 'Password cannot contain sequential numbers';
} else {
this.passwordError = '';
// Clear server-side errors when client validation passes
if (this.$wire.errors.password) {
this.$wire.clearErrors('password');
}
}
},
// Password validation getters
get passwordLength() {
return this.password && this.password.length >= 8;
},
get hasUppercase() {
return this.password && /[A-Z]/.test(this.password);
},
get hasLowercase() {
return this.password && /[a-z]/.test(this.password);
},
get hasNumber() {
return this.password && /[0-9]/.test(this.password);
},
// Update password type for toggle
get passwordType() {
return this.showPasswordToggle ? 'text' : 'password';
},
// Referral code validation
checkReferralCode() {
this.validateReferralCode();
},
validateReferralCode() {
// Referral code is optional
if (!this.referralCode || this.referralCode.trim() === '') {
this.referralCodeError = '';
this.referralCodeValid = true;
return;
}
// Convert to uppercase
this.referralCode = this.referralCode.toUpperCase().trim();
// Validate format (alphanumeric, max 20 chars)
const codeRegex = /^[A-Z0-9]+$/;
if (this.referralCode.length < 3) {
this.referralCodeError = 'Referral code must be at least 3 characters';
this.referralCodeValid = false;
} else if (this.referralCode.length > 20) {
this.referralCodeError = 'Referral code must be less than 20 characters';
this.referralCodeValid = false;
} else if (!codeRegex.test(this.referralCode)) {
this.referralCodeError = 'Referral code can only contain letters and numbers';
this.referralCodeValid = false;
} else {
this.referralCodeError = '';
this.referralCodeValid = true;
// Clear server-side errors when client validation passes
if (this.$wire.errors.referral_code) {
this.$wire.clearErrors('referral_code');
}
}
}
}
});
Livewire encountered a missing root tag when trying to render a component.
When rendering a Blade view, make sure it contains a root HTML tag.