?
Solved

Correct Spellings (i.e., replacing hotmial.com with of hotmail.com, etc.)

Posted on 2003-03-19
2
Medium Priority
?
539 Views
Last Modified: 2006-11-17
I have a form where user enters their email address. The problem is, sometimes user mistakenly enters incorrect domain name spelling i.e., hotmial.com instead of hotmail.com. I am hoping an expert can provide me with some JS which will automatically change incorrect spellings (which would be defined in script so that I can add a bunch of them) using onChange event.

For exmaple, JS would include something like:

IF hotmaol.com, replace with hotmail.com;
IF hotmal.com, replace with hotmail.com;
IF hotmial.com, replace with hotmail.com;
IF yaho.com, replace with yahoo.com;
IF ail.com, replace with aol.com;
etc.

Thanks!

Casey
0
Comment
Question by:cbradstreet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
Alopederii earned 1000 total points
ID: 8171294
<script>
rlist=new Array()

//     Chose your delimiter!
//     You must change this if you separate the
//     good e-mail address from the bad with anything
//     other than a comma.

delim=","



//     Declare your list of replacements, with the following format:
//     rlist[rlist.length]="bad_email,corrected_version"

rlist[rlist.length]="hotmial.com,hotmail.com"
rlist[rlist.length]="yaho.com,yahoo.com"
rlist[rlist.length]="ail.com,aol.com"

function correctit(tocorrect){
for(i=0;i<rlist.length;i++){
temp=rlist[i].split(delim)
tocorrect=tocorrect.split(temp[0]).join(temp[1])
}
return tocorrect
}
</script>

Put the above code in your document.  Then to use it, just add:
onBlur="this.value=correctit(this.value)"



Example:
<HTML>
<script>
rlist=new Array()

//     Chose your delimiter!
//     You must change this if you separate the
//     good e-mail address from the bad with anything
//     other than a comma.

delim=","



//     Declare your list of replacements, with the following format:
//     rlist[rlist.length]="bad_email,corrected_version"

rlist[rlist.length]="hotmial.com,hotmail.com"
rlist[rlist.length]="yaho.com,yahoo.com"
rlist[rlist.length]="ail.com,aol.com"

function correctit(tocorrect){
for(i=0;i<rlist.length;i++){
temp=rlist[i].split(delim)
tocorrect=tocorrect.split(temp[0]).join(temp[1])
}
return tocorrect
}
</script>
<BODY>
<FORM NAME="form1">
<INPUT NAME="test" onBlur="this.value=correctit(this.value)">
</FORM>
</BODY>
</HTML>
0
 

Author Comment

by:cbradstreet
ID: 8171382
Thanks Alopederii!
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question