forked from sagi/seepur
Backend support for registration validation.
terms and conditions. Issues #3 #4
This commit is contained in:
parent
b75ac5aa97
commit
1f49924963
8 changed files with 30 additions and 3083 deletions
|
@ -7,9 +7,7 @@ class IndexController {
|
|||
return view.render('home');
|
||||
} catch (e) {
|
||||
const bgIndex = Math.ceil((Math.random() * 10) % 5);
|
||||
console.log(bgIndex)
|
||||
return view.render('landing', {bgIndex});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,8 @@
|
|||
class Register {
|
||||
get rules() {
|
||||
return {
|
||||
name: 'required|min:1',
|
||||
email: 'required|email|unique:users',
|
||||
password: 'required|string|min:6',
|
||||
// validation rules
|
||||
name: 'required|min:1', email: 'required|email|unique:users',
|
||||
password: 'required|string|min:6', terms: 'required|string|min:1',
|
||||
}
|
||||
}
|
||||
get messages() {
|
||||
|
@ -15,7 +13,8 @@ class Register {
|
|||
'email.unique': 'This email is already taken',
|
||||
'required': 'This is required',
|
||||
'email.unique': 'This email is already taken',
|
||||
'password.min': 'Password must be at least 6 chars long'
|
||||
'password.min': 'Password must be at least 6 chars long',
|
||||
'terms.min': 'Must confirm terms and conditions'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -17,6 +17,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
function validateForm(): void {
|
||||
isFormValid = form.checkValidity() && isPassMatch && terms.checked;
|
||||
submit.disabled = !isFormValid;
|
||||
terms.value = terms.checked ? "on" : "";
|
||||
}
|
||||
|
||||
validateForm();
|
||||
|
|
|
@ -80,9 +80,10 @@
|
|||
<div class="field is-grouped">
|
||||
<div class="control">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" id="chk-register-terms">
|
||||
<input type="checkbox" id="chk-register-terms" name="terms">
|
||||
I agree to the <a href="#">terms and conditions</a>
|
||||
</label>
|
||||
<p class="help is-danger">{{ getErrorFor('terms') ? getErrorFor('terms') : '' }}</p>
|
||||
<div class="control">
|
||||
<button id="btn-register-submit" class="button is-link" disabled="true">Submit</button>
|
||||
</div>
|
||||
|
|
|
@ -65,9 +65,10 @@ Seepur| Register
|
|||
<div class="field">
|
||||
<div class="control">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" id="chk-register-terms">
|
||||
<input type="checkbox" id="chk-register-terms" name="terms">
|
||||
I agree to the <a href="#">terms and conditions</a>
|
||||
</label>
|
||||
<p class="help is-danger">{{ getErrorFor('terms') ? getErrorFor('terms') : '' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in a new issue