I am using html input control to feed in email address. Also, I am using required attribute but I want the input should only be from gmail.com i.e. john@gmail.com, aamir@gmail.com etc and not any other domain.
<input type="text" name="email" pattern="^[a-zA-Z0-9]+@domain.[a-zA-z]+$" required>
But this accept every domain and not only gmail.com.
NOTE: I need to do it with regex in html5 control not with javascript etc
Update: I am using razor syntax with asp.net mvc.
Advertisement
Answer
You can use this regex
^[a-zA-Z0-9]+@gmail.com$
<form> <input type="text" name="email" pattern="^[a-zA-Z0-9]+@gmail.com$" required></input> <input type='submit' placeholder='submit'/> </form>