From 99163711224708b672f7fb94f76ea4a82c68c065 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Thu, 30 Dec 2021 22:28:03 +0100 Subject: [PATCH] Remove mailto: prefix automatically in the email field --- UI/Input/ValidatedTextField.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/UI/Input/ValidatedTextField.ts b/UI/Input/ValidatedTextField.ts index 24f8435676..12e043b390 100644 --- a/UI/Input/ValidatedTextField.ts +++ b/UI/Input/ValidatedTextField.ts @@ -350,8 +350,19 @@ export default class ValidatedTextField { ValidatedTextField.tp( "email", "An email adress", - (str) => EmailValidator.validate(str), - undefined, + (str) => { + if(str.startsWith("mailto:")){ + str = str.substring("mailto:".length) + } + return EmailValidator.validate(str); + }, + str => { + if(str === undefined){return undefined} + if(str.startsWith("mailto:")){ + str = str.substring("mailto:".length) + } + return str; + }, undefined, "email"), ValidatedTextField.tp(