You'd use something like;
<input type="email" name="email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$">
So if you wanted to only allow a domain and subdomain in theory you'd use;
<input type="email" name="email" pattern="[a-z0-9._%+-]+@[example]+\.[com]{2,}/@[subdomain]+\.[example].\[com]$">
I only want to allow email responses from example.com
and subdomain.example.com
OR only allow email responses ending in .co.uk
which is most ideal.
Any help would be appreciated.
UPDATE
Using;
pattern="[a-zA-Z0-9-]+@sub.example.co.uk"
means that the validation will work.
But using:
pattern="[a-zA-Z0-9-]+@sub.example.co.uk|+@example.co.uk"
means that the validation will work but also allows domains like @gmail.com
etc.
UPDATE
Here's the code for the form.
<form action="./login.php" method="post">
<input type="email" id="email" minlength="13" maxlength="29" pattern="[a-zA-Z0-9-]+@subdomain@example.co.uk|+@example.co.uk" style="text-transform: lowercase" placeholder="Enter your email address." name="email" required=""><br>
<input type="submit">
</form>
Ideally I'd be able to set a list of allowed domains and specific email addresses so only jon@example.co.uk
, igor@example.co.uk
and stephen@example.co.uk
could submit. Can you match the beginning of the email as an array or the entire thing in the format of $allowedaddresses
to save exploding the @
from the domain.