Correcting cut and paste errors from Word

This tip describes how to correct the cut and paste errors that occur in Word.

Have you ever come across the problem; when a user cuts and pastes a document from a "word document" into a TEXTAREA...

on your notes form, the quotation marks become question marks? e.g. the user intended "the general" the form created ?the general?

This code when added to the onBlur event of a TEXTAREA will remove that error by converting the bogus ascii codes to ones which are understandable by notes.



add onBlur="RepairPasteFromWord(this)"
 to your TEXTAREA fields.

in the jsHeader
function RepairPasteFromWord(field){

/*
This function corrects the text if it has been 
cut and pasted from word.
Quotation marks do not come through as 
standard character codes and notes 
intpretes them as a ?
"This method will also work for normal 
text fields as well"
*/

var sTemp=field.value
//we are going to replace the 
var sTemp2=escape(sTemp)
//replace front quote mark "
sTemp2=sTemp2.replace
(/%u201C/gi, "%22")
//replace end quote mark "
sTemp2=sTemp2.replace
(/%u201D/gi, "%22")
//replace opening single quote mark '
sTemp2=sTemp2.replace
(/%u2018/gi, "%27")
//replace closing single quote mark '
sTemp2=sTemp2.replace
(/%u2019/gi, "%27")
field.value=unescape(sTemp2)
}


This was first published in January 2003

Dig Deeper

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close