Hi @zubata,
You're right.
Your regex works fine. I've tried it. https://regex101.com/r/bp1fR1/1
The reason mail@mail passes the browser's built-in type="email" validation is that the HTML5 email validation is not very strict. It simply checks for the @ symbol, a valid domain name (text after @), and at least one character after the final dot in the domain.
In Joomla, you can use a plugin to hook into the form submission process (e.g., onUserBeforeSave) to validate the email field.
You're right.
Your regex works fine. I've tried it. https://regex101.com/r/bp1fR1/1
The reason mail@mail passes the browser's built-in type="email" validation is that the HTML5 email validation is not very strict. It simply checks for the @ symbol, a valid domain name (text after @), and at least one character after the final dot in the domain.
In Joomla, you can use a plugin to hook into the form submission process (e.g., onUserBeforeSave) to validate the email field.
Code:
public function onUserBeforeSave($user, $isNew, $data){ $email = $data['email']; if (!filter_var($email, FILTER_VALIDATE_EMAIL) || !preg_match('/^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$/i', $email)) { throw new RuntimeException('Please provide a valid email address.'); }}
Statistics: Posted by Yiannistaos — Sat Jan 04, 2025 5:59 pm