Last Updated : Jan 1, 2023
Actually, as we know email today’s are mostly used everywhere.
Whereas user’s mobile number is less used as compare to emails for identification.
Here, as we know that email addresses contain:
- Uppercase and lowercase alphabets
- Numeric digits
- Special characters like @
- And full stop with conditions like they are not first and last character of email address and not repeat continuously.
Now, as we know that what emails contains. So, it become now easy for us to apply validations.
And today this is done with the help of Regular Expression. Let us first see Regular expression that we going to use for email validation.
- For this first of all we here create a basic structure of html. For this we use html, head, title and body with script tag. We hope you know about the basic structure of html and which html tag is used for which concept.
- Here, we first see that we create a form inside body with input type text and a button to submit that data.
- Inside this function, we store our expression which we want in email address inside a variable. And match that format with text that user feed using if condition. Here, if the data submitted by user is valid. Then a message with text Email address valid displayed on screen otherwise if data does not matches then text having message you have entered an invalid email address, try again later executed.