From 5df2c3945a8f3513181f0e428039f74a7b9d4bab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sch=C3=A4fer?= Date: Sat, 20 Mar 2021 14:37:57 +0100 Subject: [PATCH] Use browser API to indicate validity state --- snikket_web/templates/user_profile.html | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/snikket_web/templates/user_profile.html b/snikket_web/templates/user_profile.html index f420801..c9f76d0 100644 --- a/snikket_web/templates/user_profile.html +++ b/snikket_web/templates/user_profile.html @@ -43,25 +43,10 @@ if (this.files[0].size > maxsize) { var warning_header = this.dataset.warningHeader; var warning_text = this.dataset.maxsizeWarning; - var flash = document.createElement("div"); - flash.id = "avatar-alert"; - flash.classList.add("box"); - flash.classList.add("alert"); - flash.classList.add("el-5"); - flash.setAttribute("role", "alert"); - - var header = document.createElement("header"); - header.innerText = warning_header; - flash.appendChild(header); - - var p = document.createElement("p") - p.innerText = warning_text + "."; - flash.appendChild(p); - - var flashbox = document.getElementById("flashbox"); - flashbox.appendChild(flash); - + this.setCustomValidity(warning_text); this.value = null; + } else { + this.setCustomValidity(""); } };