The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> Issues with Javascript Replace
kspn
post Apr 27 2009, 01:00 AM
Post #1





Group: Members
Posts: 3
Joined: 27-April 09
Member No.: 8,448



Hi,

I am trying to get the values form a Textarea, replace any returns with '. ' and also ensure that there are no duplicates (ie) '.. ' or '. . '

So far I am having weird results. blink.gif

CODE

ProductOI = document.getElementById('ProductOI').value;
ProductOI = ProductOI.replace(/\n/g, '\. ');
ProductOI = ProductOI.replace(/\.\. /g, '\. ');
ProductOI = ProductOI.replace(/\. \. /g, '\. ');


The 'NewLine' code is working but the other two for some reason are not working as I am expecting them too. blink.gif
Each line of code run independently seems to work as expected, but when combined it fails.

Any assistance would be appreciated.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 5th July 2015 - 12:31 PM