Commit c1bd8146 authored by Zohten's avatar Zohten

added comments

parent a6accf9b
......@@ -46,21 +46,30 @@ export default {
this.showBackError = false; //TODO
},
onSubmit: async function(){
// If we press back, we go back
if (event.submitter.id=='back') {
this.$router.push('/');
}
// Test if password match the confirm password
this.showPwdError = (document.getElementById('password1').value !== document.getElementById('password2').value);
if (this.showPwdError) {
return;
}
// Test if mail is valid
this.showMailError = !validateEmail(document.getElementById('mail').value);
if (this.showMailError) {
return;
}
// Test if Email exist/Pseudo exist
this.showBackError = false; //TODO
if (this.showBackError) {
return;
}
if (event.submitter.id=='back') {
this.$router.push('/');
}
// Post new user if all tests are ok
if (event.submitter.id=='validate') {
let request = await fetch('http://localhost/index.php/user',
{
......@@ -86,6 +95,7 @@ export default {
}
}
}
// Function to check if the str email is valide (true if this is the case)
function validateEmail (email) {
const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return re.test(String(email).toLowerCase());
......
Markdown is supported
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