mirror of https://github.com/xfarrow/blink
New register page
This commit is contained in:
parent
6414eff42f
commit
e1bb44ca18
|
@ -1,6 +1,7 @@
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
|
<title>Blink - Sign In</title>
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
||||||
|
@ -53,9 +54,9 @@
|
||||||
<!-- Email input -->
|
<!-- Email input -->
|
||||||
<div class="form-outline mb-4">
|
<div class="form-outline mb-4">
|
||||||
<input type="email" id="email" class="form-control form-control-lg"
|
<input type="email" id="email" class="form-control form-control-lg"
|
||||||
placeholder="Enter a valid email address" onblur="emailFieldLosesFocus();" />
|
placeholder="Enter your email address" onblur="emailFieldLosesFocus();" />
|
||||||
<div class="invalid-feedback">
|
<div class="invalid-feedback">
|
||||||
Please enter a valid e-mail
|
Please enter an email address
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -82,8 +83,7 @@
|
||||||
<div class="text-center text-lg-start mt-4 pt-2">
|
<div class="text-center text-lg-start mt-4 pt-2">
|
||||||
<button type="button" onclick="login()" class="btn btn-primary btn-lg"
|
<button type="button" onclick="login()" class="btn btn-primary btn-lg"
|
||||||
style="padding-left: 2.5rem; padding-right: 2.5rem;">Login</button>
|
style="padding-left: 2.5rem; padding-right: 2.5rem;">Login</button>
|
||||||
<p class="small fw-bold mt-2 pt-1 mb-0">Don't have an account? <a href="register.html"
|
<p class="small fw-bold mt-2 pt-1 mb-0">Don't have an account? <a href="register.html">Register</a></p>
|
||||||
class="link-danger">Register</a></p>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -99,13 +99,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function is responsible for the log-in process
|
* This function is responsible for the log-in process
|
||||||
*/
|
*/
|
||||||
async function login() {
|
async function login() {
|
||||||
const email = document.getElementById("email").value;
|
const email = document.getElementById("email").value;
|
||||||
const password = document.getElementById("password").value;
|
const password = document.getElementById("password").value;
|
||||||
|
|
||||||
if (!email || !password) {
|
if (!validateFields()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,9 +129,22 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function is responsible for loading a random stock photo seen on the
|
* Validate the field before the submit. This helps to prevent useless API
|
||||||
* left side of the page
|
* calls. Retrurns true or false
|
||||||
*/
|
*/
|
||||||
|
function validateFields(){
|
||||||
|
const email = document.getElementById("email").value;
|
||||||
|
const password = document.getElementById("password").value;
|
||||||
|
if(!email || !password || !validateEmail(email) || password.length < 5){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function is responsible for loading a random stock photo seen on the
|
||||||
|
* left side of the page
|
||||||
|
*/
|
||||||
function loadImage() {
|
function loadImage() {
|
||||||
const random = Math.floor(Math.random() * 4);
|
const random = Math.floor(Math.random() * 4);
|
||||||
if (random == 0) {
|
if (random == 0) {
|
||||||
|
@ -146,9 +159,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function gets called when the e-mail field loses focus. This is
|
* This function gets called when the e-mail field loses focus. This is
|
||||||
* done to inform the user whether the entered e-mail is in a valid format
|
* done to inform the user whether the entered e-mail is in a valid format
|
||||||
*/
|
*/
|
||||||
function emailFieldLosesFocus() {
|
function emailFieldLosesFocus() {
|
||||||
const emailField = document.getElementById("email");
|
const emailField = document.getElementById("email");
|
||||||
if (!emailField.value || !validateEmail(emailField.value)) {
|
if (!emailField.value || !validateEmail(emailField.value)) {
|
||||||
|
@ -159,20 +172,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Validates an e-mail using a RegExpression
|
* This function gets called when the password field loses focus. This is
|
||||||
*/
|
* done to inform the user that they are required to enter a password
|
||||||
function validateEmail(email) {
|
*/
|
||||||
return String(email)
|
|
||||||
.toLowerCase()
|
|
||||||
.match(
|
|
||||||
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|.(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This function gets called when the password field loses focus. This is
|
|
||||||
* done to inform the user that they are required to enter a password
|
|
||||||
*/
|
|
||||||
function passwordFieldLosesFocus() {
|
function passwordFieldLosesFocus() {
|
||||||
const passwordField = document.getElementById("password");
|
const passwordField = document.getElementById("password");
|
||||||
if (!passwordField.value) {
|
if (!passwordField.value) {
|
||||||
|
@ -183,8 +185,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function shows an error using a Bootstrap's alert element
|
* This function shows an error using a Bootstrap's alert element
|
||||||
*/
|
*/
|
||||||
function showError(message) {
|
function showError(message) {
|
||||||
const alertDiv = document.getElementById('hiddenAlertMessage');
|
const alertDiv = document.getElementById('hiddenAlertMessage');
|
||||||
alertDiv.innerHTML = message;
|
alertDiv.innerHTML = message;
|
||||||
|
|
|
@ -1,89 +1,248 @@
|
||||||
<!DOCTYPE html>
|
<html>
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<title>Blink - Sign Up</title>
|
||||||
<title>Sign Up to Blink</title>
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||||
<link rel="stylesheet" href="../css/login-register.css">
|
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
||||||
|
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous">
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="login-form-wrap">
|
|
||||||
<h2>Sign Up</h2>
|
|
||||||
<form id="login-form">
|
|
||||||
|
|
||||||
<p>
|
<div class="alert alert-success" role="alert" id="successAlert" style="display: none;">
|
||||||
<input type="text" id="displayname" name="displayname" placeholder="Your name" required><i
|
|
||||||
class="validation"><span></span><span></span></i>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<input type="email" id="email" name="email" placeholder="Email Address" required><i
|
|
||||||
class="validation"><span></span><span></span></i>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<input type="password" id="password" name="password" placeholder="Password" required><i
|
|
||||||
class="validation"><span></span><span></span></i>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<button type="button" onclick="register(); return false;">Register</button>
|
|
||||||
</p>
|
|
||||||
</form>
|
|
||||||
<div id="create-account-wrap">
|
|
||||||
<p>Already a member? <a href="./login.html">Login</a>
|
|
||||||
<p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<script src="../js/constants.js"></script>
|
<div class="alert alert-danger" role="alert" id="errorAlert" style="display: none;">
|
||||||
<script src="../js/utils.js"></script>
|
</div>
|
||||||
|
|
||||||
<script>
|
<div class="bg-light py-3 py-md-5">
|
||||||
async function register() {
|
<div class="container">
|
||||||
const display_name = document.getElementById('displayname').value;
|
<div class="row justify-content-md-center">
|
||||||
const email = document.getElementById('email').value;
|
<div class="col-12 col-md-11 col-lg-8 col-xl-7 col-xxl-6">
|
||||||
const password = document.getElementById('password').value;
|
<div class="bg-white p-4 p-md-5 rounded shadow-sm">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="text-center mb-5">
|
||||||
|
<!-- <a href="#!">
|
||||||
|
<img src="./assets/img/bsb-logo.svg" alt="BootstrapBrain Logo" width="175"
|
||||||
|
height="57">
|
||||||
|
</a> -->
|
||||||
|
<h1 style="font-family: sans-serif">Sign up to Blink</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row gy-3 gy-md-4 overflow-hidden">
|
||||||
|
<div class="col-12">
|
||||||
|
<label for="firstName" class="form-label">Name <span
|
||||||
|
class="text-danger">*</span></label>
|
||||||
|
<div class="input-group">
|
||||||
|
<span class="input-group-text">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
|
||||||
|
fill="currentColor" class="bi bi-person-vcard" viewBox="0 0 16 16">
|
||||||
|
<path
|
||||||
|
d="M5 8a2 2 0 1 0 0-4 2 2 0 0 0 0 4m4-2.5a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 0 1h-4a.5.5 0 0 1-.5-.5M9 8a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 0 1h-4A.5.5 0 0 1 9 8m1 2.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5" />
|
||||||
|
<path
|
||||||
|
d="M2 2a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2zM1 4a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1H8.96c.026-.163.04-.33.04-.5C9 10.567 7.21 9 5 9c-2.086 0-3.8 1.398-3.984 3.181A1.006 1.006 0 0 1 1 12z" />
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
<input type="text" class="form-control" name="displayname" id="displayname" required
|
||||||
|
onblur="displaynameFieldLosesFocus();">
|
||||||
|
<div class="invalid-feedback">
|
||||||
|
Please fill out this field
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-12">
|
||||||
|
<label for="email" class="form-label">Email <span class="text-danger">*</span></label>
|
||||||
|
<div class="input-group">
|
||||||
|
<span class="input-group-text">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
|
||||||
|
fill="currentColor" class="bi bi-envelope" viewBox="0 0 16 16">
|
||||||
|
<path
|
||||||
|
d="M0 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V4Zm2-1a1 1 0 0 0-1 1v.217l7 4.2 7-4.2V4a1 1 0 0 0-1-1H2Zm13 2.383-4.708 2.825L15 11.105V5.383Zm-.034 6.876-5.64-3.471L8 9.583l-1.326-.795-5.64 3.47A1 1 0 0 0 2 13h12a1 1 0 0 0 .966-.741ZM1 11.105l4.708-2.897L1 5.383v5.722Z" />
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
<input type="email" class="form-control" name="email" id="email" required
|
||||||
|
onblur="emailFieldLosesFocus();">
|
||||||
|
<div class="invalid-feedback">
|
||||||
|
Please enter an email address
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-12">
|
||||||
|
<label for="password" class="form-label">Password <span
|
||||||
|
class="text-danger">*</span></label>
|
||||||
|
<div class="input-group">
|
||||||
|
<span class="input-group-text">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
|
||||||
|
fill="currentColor" class="bi bi-key" viewBox="0 0 16 16">
|
||||||
|
<path
|
||||||
|
d="M0 8a4 4 0 0 1 7.465-2H14a.5.5 0 0 1 .354.146l1.5 1.5a.5.5 0 0 1 0 .708l-1.5 1.5a.5.5 0 0 1-.708 0L13 9.207l-.646.647a.5.5 0 0 1-.708 0L11 9.207l-.646.647a.5.5 0 0 1-.708 0L9 9.207l-.646.647A.5.5 0 0 1 8 10h-.535A4 4 0 0 1 0 8zm4-3a3 3 0 1 0 2.712 4.285A.5.5 0 0 1 7.163 9h.63l.853-.854a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .708 0l.646.647.793-.793-1-1h-6.63a.5.5 0 0 1-.451-.285A3 3 0 0 0 4 5z" />
|
||||||
|
<path d="M4 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0z" />
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
<input type="password" class="form-control" name="password" id="password" value=""
|
||||||
|
required onblur="passwordFieldLosesFocus();">
|
||||||
|
<div class="invalid-feedback" id="passwordErrorLabel">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" value="" name="iAgree" id="iAgree"
|
||||||
|
required>
|
||||||
|
<label class="form-check-label text-secondary" for="iAgree">
|
||||||
|
I agree to the <a href="./privacypolicy_and_tou/Terms-Of-Use.html"
|
||||||
|
class="link-primary text-decoration-none">terms
|
||||||
|
and conditions</a> and to the <a class="link-primary text-decoration-none"
|
||||||
|
href="./privacypolicy_and_tou/Privacy-Policy-English.html">privacy
|
||||||
|
policy</a>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="d-grid">
|
||||||
|
<button class="btn btn-primary btn-lg" type="button" onclick="register();">Sign
|
||||||
|
Up</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<hr class="mt-5 mb-4 border-secondary-subtle">
|
||||||
|
<p class="m-0 text-secondary text-center">Already have an account? <a href="#!"
|
||||||
|
class="link-primary text-decoration-none">Sign in</a></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
if (!display_name || !email || !password) {
|
<script src="../js/constants.js"></script>
|
||||||
alert('Please fill in all fields');
|
<script src="../js/utils.js"></script>
|
||||||
return;
|
<script>
|
||||||
}
|
async function register() {
|
||||||
|
const display_name = document.getElementById('displayname').value;
|
||||||
|
const email = document.getElementById('email').value;
|
||||||
|
const password = document.getElementById('password').value;
|
||||||
|
|
||||||
const options = {
|
if (!validateFields()) {
|
||||||
method: 'POST',
|
return;
|
||||||
headers: createHeaders(null),
|
|
||||||
body: JSON.stringify({
|
|
||||||
display_name,
|
|
||||||
email,
|
|
||||||
password
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
fetch(`${API_URL}/persons`, options)
|
|
||||||
.then(response => {
|
|
||||||
response.json().then(data => {
|
|
||||||
if (response.ok) {
|
|
||||||
if (!data.enabled) { // is the user already enabled or do they need email verification?
|
|
||||||
alert("Congratulations! You've successfully registered to Blink. " +
|
|
||||||
"Please click on the e-mail we sent you to confirm your account");
|
|
||||||
} else {
|
|
||||||
alert("Congratulations! You've successfully registered to Blink. " +
|
|
||||||
"You can now log in");
|
|
||||||
}
|
|
||||||
window.location.href = '/login.html';
|
|
||||||
} else {
|
|
||||||
callbackErrors(data.errors, alert);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
})
|
const options = {
|
||||||
.catch(err => {
|
method: 'POST',
|
||||||
alert("An error has occurred :-( please try again later");
|
headers: createHeaders(null),
|
||||||
console.error(err);
|
body: JSON.stringify({
|
||||||
});
|
display_name,
|
||||||
return false;
|
email,
|
||||||
}
|
password
|
||||||
</script>
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
fetch(`${API_URL}/persons`, options)
|
||||||
|
.then(response => {
|
||||||
|
response.json().then(data => {
|
||||||
|
if (response.ok) {
|
||||||
|
clearInputFields();
|
||||||
|
if (!data.enabled) { // is the user already enabled or do they need email verification?
|
||||||
|
showSuccessAlert("Congratulations! You've successfully registered to Blink. " +
|
||||||
|
"Please click on the e-mail we sent you to confirm your account");
|
||||||
|
} else {
|
||||||
|
showSuccessAlert("Congratulations! You've successfully registered to Blink. " +
|
||||||
|
"You can now <a href='login.html'>log in</a>");
|
||||||
|
}
|
||||||
|
window.location.href = '/login.html';
|
||||||
|
} else {
|
||||||
|
callbackErrors(data.errors, showErrorAlert);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
alert("An error has occurred :-( please try again later");
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function gets called when the displayname field loses focus.
|
||||||
|
* This is
|
||||||
|
* done to inform the user that they need to enter at least one
|
||||||
|
* character in said field.
|
||||||
|
*/
|
||||||
|
function displaynameFieldLosesFocus() {
|
||||||
|
const nameField = document.getElementById("displayname");
|
||||||
|
if (!nameField.value) {
|
||||||
|
nameField.classList.add("is-invalid");
|
||||||
|
} else {
|
||||||
|
nameField.classList.remove("is-invalid");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function gets called when the e-mail field loses focus. This is
|
||||||
|
* done to inform the user whether the entered e-mail is in a valid format
|
||||||
|
*/
|
||||||
|
function emailFieldLosesFocus() {
|
||||||
|
const emailField = document.getElementById("email");
|
||||||
|
if (!emailField.value || !validateEmail(emailField.value)) {
|
||||||
|
emailField.classList.add("is-invalid");
|
||||||
|
} else {
|
||||||
|
emailField.classList.remove("is-invalid");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function gets called when the password field loses focus. This is
|
||||||
|
* done to inform the user that they are required to enter a password
|
||||||
|
*/
|
||||||
|
function passwordFieldLosesFocus() {
|
||||||
|
const passwordField = document.getElementById("password");
|
||||||
|
if (!passwordField.value) {
|
||||||
|
passwordField.classList.add("is-invalid");
|
||||||
|
document.getElementById('passwordErrorLabel').innerHTML = 'Please fill out this field';
|
||||||
|
} else if (passwordField.value.length < 5) {
|
||||||
|
passwordField.classList.add("is-invalid");
|
||||||
|
document.getElementById('passwordErrorLabel').innerHTML = 'Password must be at least 5 characters';
|
||||||
|
} else {
|
||||||
|
passwordField.classList.remove("is-invalid");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Validate the field before the submit. This helps to prevent useless API
|
||||||
|
* calls. Retrurns true or false
|
||||||
|
*/
|
||||||
|
function validateFields() {
|
||||||
|
const email = document.getElementById("email").value;
|
||||||
|
const password = document.getElementById("password").value;
|
||||||
|
const displayname = document.getElementById("displayname").value;
|
||||||
|
const iAgree = document.getElementById('iAgree');
|
||||||
|
if (!email || !password || !displayname || !validateEmail(email) || password.length < 5 || !iAgree
|
||||||
|
.checked) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function showSuccessAlert(message) {
|
||||||
|
const successAlert = document.getElementById('successAlert');
|
||||||
|
successAlert.innerHTML = message;
|
||||||
|
successAlert.style.display = 'block';
|
||||||
|
}
|
||||||
|
|
||||||
|
function showErrorAlert(message){
|
||||||
|
const errorAlert = document.getElementById('errorAlert');
|
||||||
|
errorAlert.innerHTML = message;
|
||||||
|
errorAlert.style.display = 'block';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
|
@ -10,6 +10,20 @@ function getCookie(name) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates an e-mail using a RegExpression
|
||||||
|
*
|
||||||
|
* @param {*} email
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
function validateEmail(email) {
|
||||||
|
return String(email)
|
||||||
|
.toLowerCase()
|
||||||
|
.match(
|
||||||
|
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|.(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function callbackErrors(errors, func) {
|
function callbackErrors(errors, func) {
|
||||||
errors.forEach(error => func(error.msg));
|
errors.forEach(error => func(error.msg));
|
||||||
}
|
}
|
||||||
|
@ -19,4 +33,11 @@ function createHeaders(token) {
|
||||||
"Content-type": "application/json; charset=UTF-8",
|
"Content-type": "application/json; charset=UTF-8",
|
||||||
"Authorization": `Bearer ${token}`
|
"Authorization": `Bearer ${token}`
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearInputFields() {
|
||||||
|
var inputs = document.querySelectorAll('input');
|
||||||
|
inputs.forEach(function(input) {
|
||||||
|
input.value = '';
|
||||||
|
});
|
||||||
}
|
}
|
Loading…
Reference in New Issue