Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 112533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:33:35+00:00 2026-05-11T02:33:35+00:00

I notice sometimes users mistype their email address (in a contact-us form), for example,

  • 0

I notice sometimes users mistype their email address (in a contact-us form), for example, typing @yahho.com, @yhoo.com, or @yahoo.co instead of @yahoo.com

I feel that this can be corrected on-the-spot with some javascript. Simply check the email address for possible mistakes, such as the ones listed above, so that if the user types his_email@yhoo.com, a non-obtrusive message can be displayed, or something like that, suggesting that he probably means @yahoo.com, and asking to double check he typed his email correctly.

The Question is:
How can I detect -in java script- that a string is very similar to ‘yahoo’ or ‘yahoo.com’? or in general, how can I detect the level of similarity between two strings?

P.S. (this is a side note) In my specific case, the users are not native English speakers, and most of them are no where near fluent, the site itself is not in English.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T02:33:35+00:00Added an answer on May 11, 2026 at 2:33 am

    Here’s a dirty implementation that could kind of get you some simple checks using the Levenshtein distance. Credit for the ‘levenshteinenator’ goes to this link. You would add whatever popular domains you want to the domains array and it would check to see if the distance of the host part of the email entered is 1 or 2 which would be reasonably close to assume there’s a typo somewhere.

    levenshteinenator = function(a, b) {     var cost;      // get values     var m = a.length;     var n = b.length;      // make sure a.length >= b.length to use O(min(n,m)) space, whatever that is     if (m < n) {         var c=a;a=b;b=c;         var o=m;m=n;n=o;     }      var r = new Array();     r[0] = new Array();     for (var c = 0; c < n+1; c++) {         r[0][c] = c;     }      for (var i = 1; i < m+1; i++) {         r[i] = new Array();         r[i][0] = i;         for (var j = 1; j < n+1; j++) {             cost = (a.charAt(i-1) == b.charAt(j-1))? 0: 1;             r[i][j] = minimator(r[i-1][j]+1,r[i][j-1]+1,r[i-1][j-1]+cost);         }     }      return r[m][n]; }  // return the smallest of the three values passed in minimator = function(x,y,z) {     if (x < y && x < z) return x;     if (y < x && y < z) return y;     return z; }  var domains = new Array('yahoo.com','google.com','hotmail.com'); var email = 'whatever@yahoo.om'; var parts = email.split('@'); var dist; for(var x=0; x < domains.length; x++) {     dist = levenshteinenator(domains[x], parts[1]);     if(dist == 1 || dist == 2) {         alert('did you mean ' + domains[x] + '?');     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.