![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
I realize this sounds basic, but I have been having trouble getting code that will fill in a text box. What I have is a text box in a form where a person enters a price in the form "XX.YY" However if its $50 they may just enter 50 and then I would need the javascript to detect that they have changed the box with focus and if there is no decimal, add a decimal and two zeros. Any code snippits are a point in the right direction would be appreciated. |
#2
| |||
| |||
|
|
Blaine HIlton wrote on 27 jul 2003 in comp.lang.javascript: I realize this sounds basic, but I have been having trouble getting code that will fill in a text box. What I have is a text box in a form where a person enters a price in the form "XX.YY" However if its $50 they may just enter 50 and then I would need the javascript to detect that they have changed the box with focus and if there is no decimal, add a decimal and two zeros. Any code snippits are a point in the right direction would be appreciated. input onchange="this.value=(+this.value).toFixed(2)" toFixed() can be a bit buggy, test it thoroughly. |
|
Grant Wagner <gwagner (AT) agricoreunited (DOT) com |
![]() |
| Thread Tools | |
| Display Modes | |
| |