View Full Version : Cursor position in text field

08-06-2008, 03:03 PM
Hello everybody,

I have a little problem here, maby you could help.. Here it is:

I have a form and few input fields in it. Every input field has some kind of numeric value. For example:

<form name="MyForm">
<input type="text" name="MyField1" value="0">
<input type="text" name="MyField2" value="20">
<input type="text" name="MyField3" value="0,0">

I need an onFocus event, which would check if focused field value is "0", and if it is, replace that value with ",0" (comma, zero), and put cursor in front of that text (cursor, comma, zero). If value is not 0, then it shoud leave current value and select all the numeric string in field (all the numbers should be in blue background, and replaced if any key pressed).

Could someone help me do it practically with javascript, please?

Hope you understood me, sorry for the mistakes, i'm not from english-speaking country.

08-06-2008, 05:24 PM
Thanks, but found solution myself.

Sorry, for making useless post.