Commit ce8f97fa authored by jbuechele's avatar jbuechele
Browse files

added validation to register page

parent d3abdaf8
......@@ -37,7 +37,7 @@
</div>
</#if>
</#if>
<form method="POST">
<form action="${url.registrationAction}" method="post">
<div class="form-group">
<label for="firstName">First name</label>
......@@ -51,7 +51,7 @@
<div class="form-group">
<label for="mobileNumber">Mobile number</label>
<input id="mobileNumber" type="text" class="form-control" name="mobileNumber" required>
<input id="mobileNumber" type="text" class="form-control" name="mobileNumber">
</div>
<div class="form-group">
......@@ -62,20 +62,22 @@
<div class="form-group">
<label for="password">Password</label>
<input id="password" type="password" class="form-control" name="password" required>
<div class="invalid-feedback">${msg("errorNotValidPassword")}</div>
</div>
<div class="form-group">
<label for="confirmPassword">Confirm password</label>
<input id="confirmPassword" type="password" class="form-control" name="confirmPassword" required>
<label for="password-confirm">Confirm password</label>
<input id="password-confirm" type="password" class="form-control" name="password-confirm" required>
<div class="invalid-feedback">${msg("errorNotSamePassword")}</div>
</div>
<div class="form-group">
<label>
<input type="checkbox" name="aggree" value="1"> I agree to the Terms and Conditions
<input id="agreeTerms" type="checkbox" name="agree" value="1"> I agree to the Terms and Conditions
</label>
</div>
<div class="form-group no-margin">
<button type="submit" class="btn btn-primary btn-block btn-main-action">
<button id="registerBtn" type="submit" class="btn btn-primary btn-block btn-main-action" disabled>
Register
</button>
</div>
......
......@@ -36,7 +36,47 @@ $(function() {
});
});
function languageSelected() {
var redirectUrl = $('#language-picker-dropdown').val();
window.location.href = redirectUrl;
}
\ No newline at end of file
function removeError(event) {
if($('#' + event.target.id).hasClass("is-invalid")) {
$('#' + event.target.id).removeClass("is-invalid");
}
}
function addError(event) {
$('#' + event.target.id).addClass("is-invalid");
}
$(document).ready(() => {
$("#password-confirm").change((event) => {
const password = $("#password").val();
if(password !== $("#password-confirm").val()) {
addError(event);
}
});
$("#password-confirm").focus(removeError);
$("#password").change((event) => {
const regex = new RegExp('^(?=.*[A-Z])(?=.*[0-9])(?=.*[a-z]).{8,}$');
if(!regex.test($('#password').val())) {
addError(event);
}
});
$('#password').focus(removeError);
$('#language-picker-dropdown').change(() => {
var redirectUrl = $('#language-picker-dropdown').val();
window.location.href = redirectUrl;
})
$('#agreeTerms').change((event) => {
if (!$('#agreeTerms').is(":checked")) {
$("#registerBtn").prop('disabled', true);
} else {
$("#registerBtn").prop('disabled', false);
}
});
});
......@@ -67,7 +67,7 @@
<div class="form-inline">
<div class="form-group">
<select id="language-picker-dropdown" class="form-control form-control-sm" onchange="languageSelected()">
<select id="language-picker-dropdown" class="form-control form-control-sm">
<option id="kc-current-locale-link">${locale.current}</option>
<#list locale.supported as l>
<option value="${l.url}">${l.label}</option>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment