iis6newbie
Technical User
Hello all,
Can someone help me with the following problem?
I have a text field for date input. The text field already had --/--/---- in there.
When user input 1, it should have something like 1-/--/---- . and the cursor should be next to 1.
I used functions onkeyup/onkeydown and window.event.keycode to get the key from keyboard.
var string = '--/--/----'
var key = window.event.keyCode
var num = key - 48 //convert to number 0-9
var index = string.indexOf('-')
var curValue = getElementIdBy"txtDate"].value
document.getElementIdBy["txtDate"].value= curValue.substring(0,index+1) + num + string.indexOf(10,index+1)
The problem is that the cursor moved to the end of the string.
I tried to set
window.event.keyCode = 37 in the loop to move the arrow to the left. But it just moved only one time. Because the flags did not change.
I have thought of toggling insert/overwritten key. by set window.event.keyCode=45, But it did not work.
Thanks for any suggestion or comments
Can someone help me with the following problem?
I have a text field for date input. The text field already had --/--/---- in there.
When user input 1, it should have something like 1-/--/---- . and the cursor should be next to 1.
I used functions onkeyup/onkeydown and window.event.keycode to get the key from keyboard.
var string = '--/--/----'
var key = window.event.keyCode
var num = key - 48 //convert to number 0-9
var index = string.indexOf('-')
var curValue = getElementIdBy"txtDate"].value
document.getElementIdBy["txtDate"].value= curValue.substring(0,index+1) + num + string.indexOf(10,index+1)
The problem is that the cursor moved to the end of the string.
I tried to set
window.event.keyCode = 37 in the loop to move the arrow to the left. But it just moved only one time. Because the flags did not change.
I have thought of toggling insert/overwritten key. by set window.event.keyCode=45, But it did not work.
Thanks for any suggestion or comments