I have an asp text box for decimal numbers.
I have a jscript function to replace the num pad “.” character by the decimal separator used in the user culture(ex: en-US -> decimal separator: “.” pt-PT -> decimal separator: ‘,’)
here’s my function:
//method that substitutes num pad '.' with the current user culture decimal separator when num pad '.' key is hit
function onKeyDownPutDecimalSeparator(e, textBox) {
var unicode = e.charCode ? e.charCode : e.keyCode;
if (unicode == 110) {
e.returnValue = false;
e.cancel = true;
textBox.value = textBox.value.concat(decimalSeparator);
}
}
this is working fine on most browsers, including chrome and IE8, but in IE9 instead of
replacing, for ex. 1.2 -> 1,2,
is doing something like:
1.2 -> 1,.2 and when the text box looses focus, 1,2
the final value “1,2” is what i want, but that middle step when the user can actually see “1,.2” it’s just awfull
any tip on that?
Thanks
Instead of
Try