Skip to main content
Participant
July 25, 2024
Question

Textfeld mit Mailformatierung

  • July 25, 2024
  • 1 reply
  • 295 views

Hallo liebe Community,

wie kann ich ein Textfeld im Formular so formatieren, dass ausschließlich die Eingabe einer Mailadresse (also etwas mit @-Zeichen) akzeptiert wird. Leider finde ich diese Funktion nirgends.

Ich freue mich sehr über Unterstützung.

Herzliche Grüße und vorab ganz lieben Dank!

HA

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
July 25, 2024

There are a couple of undocumented functions that can do it, but it's better not to rely on them. I used the code from one of them and adjusted it a bit, so it can be embedded in the file directly. Use this code as the custom validation script of your email field:

 

if (event.value) {
	event.rc = validateEmailAddress(event.value);
	if (!event.rc) app.alert("Invalid email address.");
}

function validateEmailAddress(addr) {
    var emailRE = /^([a-zA-Z0-9_\-\.\/]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,5}|[0-9]{1,3})(\]?)$/;
    return addr.match(emailRE) != null;
}