Email typo fixer

Your task is to check if there are possible typos in the entered email and try to suggest a correct email address.

Requirements:

  • By default, the input should be empty.
  • Support only the following domains: gmail.com, outlook.com, yahoo.com.
  • Assume the following vocabulary:
    • "Main domain" is the part "gmail", "outlook" or "yahoo".
    • "Extension domain" is "com".
  • Show a suggestion if the "main domain" has a single typo.
    Example:
    • For user1@gmaxl.com, the suggestion is user1@gmail.com.
    • For user1@yatoo.com, the suggestion is user1@yahoo.com.
    • For user1@outloox.com, the suggestion is user1@outlook.com.
    Don't suggest if there 2 or more typos.
  • Show a suggestion if the "main domain" has 1 missing character.
    Example:
    • For user1@gmai.com, the suggestion is user1@gmail.com.
    • For user1@yaho.com, the suggestion is user1@yahoo.com.
    • For user1@oulook.com, the suggestion is user1@outlook.com.
    Don't suggest if 2 or more characters are missing.
  • Show a suggestion if the "main domain" has one extra character.
    Example:
    • For user1@gmaill.com, the suggestion is user1@gmail.com.
    • For user1@yahooo.com, the suggestion is user1@yahoo.com.
    • For user1@ooutlook.com, the suggestion is user1@oulook.com.
    Don't suggest if there 2 or more extra characters.
  • Show a suggestion if "Extension domain" is different.
    Example:
    • For user1@gmail.abc, the suggestion is user1@gmail.com.
    • For user1@gmail.co, the suggestion is user1@gmail.com.
    • For user1@gmail.yyyyy, the suggestion is user1@gmail.com.
  • Show a suggestion if the "Extension domain" is different and the "Main domain" can be fixed using the rules above.
    Example:
    • For user1@gmai.abc, the suggestion is user1@gmail.com.
    • For user1@gmaail.co, the suggestion is user1@gmail.com.
    • For user1@xmail.yyyyy, the suggestion is user1@gmail.com.
  • Don't show a suggestion if the email is invalid (e.g. missing "@" character) or if there are multiple domain levels (e.g. "user1@gmail.abc.com").
  • Clicking on the suggestion should replace the input value and hide the suggestion.

You are free to add classes, styles, ids, but don't edit or remove data-test attributes.
Create an account to start coding
Create account