Jump to content


Replace value in input form field

  • Please log in to reply
2 replies to this topic

#1 AndieB

  • Members
  • PipPipPip
  • Advanced Member
  • 77 posts
  • LocationSweden
  • Age:37

Posted 16 September 2006 - 08:07 PM

Hello all Gurus!

I'm not at all good coding Javascript, so I hope someone among you reading this can help me out.

I want a Javascript function that replaces a comma "," to a dot "." in a numeric input into a input field in a form. The function should be executed immediately when leaving the input fields focus, I guess it is with the onBlur function.

Can anyone help me out?

Thanks in advance!

" Start by looking in the mirror before pointing the finger outwards... "
" Nothing can be, until it has passed your mind... "

#2 degsy

  • Members
  • PipPip
  • Member
  • 20 posts

Posted 18 September 2006 - 02:56 PM

Something like this should work

<input name="textfield" type="text" value="123.456.abc" onblur="this.value=this.value.replace(/\./g,',');">

#3 fenway

  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 20 September 2006 - 12:55 PM

That JS onblur handler will actually do the inverse... but you should probably do this onsubmit as well.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users