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-][email protected]"
means that the validation will work.
But using:
pattern="[a-zA-Z0-9-][email protected]|[email protected]"
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-]+@[email protected]|[email protected]" 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 [email protected]
, [email protected]
and [email protected]
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.