Factoring the model user and correcting password

This commit is contained in:
Chris Mann 2023-07-22 11:37:43 +02:00
parent b8f125cb0f
commit 97c9d8def9

View file

@ -101,6 +101,7 @@ function changeGivenNameOrSurname () {
displayname = document.getElementById("displayname"); displayname = document.getElementById("displayname");
username = document.getElementById("username"); username = document.getElementById("username");
displayname.value = givenname.value + " " + surname.value displayname.value = givenname.value + " " + surname.value
changeDisplayname();
} }
function changeDisplayname () { function changeDisplayname () {
givenname = document.getElementById("givenname"); givenname = document.getElementById("givenname");
@ -108,6 +109,7 @@ function changeDisplayname () {
displayname = document.getElementById("displayname"); displayname = document.getElementById("displayname");
username = document.getElementById("username"); username = document.getElementById("username");
username.value = displayname.value.toLowerCase().replace(/[^A-z0-9.-]/g, '').replace(/^[.-]/, '').replace(/[.-]$/, ''); username.value = displayname.value.toLowerCase().replace(/[^A-z0-9.-]/g, '').replace(/^[.-]/, '').replace(/[.-]$/, '');
changeUsername();
} }
function changeUsername () { function changeUsername () {
givenname = document.getElementById("givenname"); givenname = document.getElementById("givenname");
@ -117,8 +119,10 @@ function changeUsername () {
mail = document.getElementById("mail"); mail = document.getElementById("mail");
mail.value = username.value + "@lesgv.com"; mail.value = username.value + "@lesgv.com";
} }
document.getElementById("username").addEventListener("change",changeUsername); document.getElementById("givenname").addEventListener("change",changeGivenNameOrSurname);
document.getElementById("surname").addEventListener("change",changeGivenNameOrSurname);
document.getElementById("displayname").addEventListener("change",changeDisplayname); document.getElementById("displayname").addEventListener("change",changeDisplayname);
document.getElementById("username").addEventListener("change",changeUsername);
</script> </script>
{{end}} {{end}}
{{end}} {{end}}