Replaceing ampersands

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JSbeginner
    New Member
    • Nov 2008
    • 1

    Replaceing ampersands

    Hello,

    I'm new to javascript and need a hand.

    I have a form with an input field and text area, that I need to replace any input '&' with the word 'and'.

    How would I accomplish this with an "onblur" event.

    Thank you
  • mrhoo
    Contributor
    • Jun 2006
    • 428

    #2
    element={value: 'Lewis & Clark & John & James'};

    element.value=e lement.value.re place(/ *& */g,' and ');
    alert(element.v alue)

    Comment

    Working...