indicates the minimum and maximum number of characters.
This will allow domain names with 2, 3 and 4 characters e.g.; us, tx, org, com, net, wxyz).
On the final line we call test method for our regular expression and pass the email address as input.
If the input email address satisfies our regular expression, ‘test’ will return true otherwise it will return false. You can call this method whenever you want to validate email address.
Through Java Script, we can validate name, password, email, date, mobile number etc fields.