Skip to content
Advertisement

How would I make the html5 input to accept only email addresses from gmail.com using patter attribute?

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.

JavaScript

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

JavaScript

enter image description here

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement