T
Tim Slattery
I'm trying to make a text input field accept only digits and period,
and only one period. I also want things like delete, left/right arrow,
backspace, home, and end to work.
What I've found is that the event object is different in IE and
Firefox. In IE, I have to use the keyCode property to find out what
was pressed, in Firefox I use charCode.
But...46 is the code for period. But in Firefox's charCode property
that seems also to be the code for the "Delete" key.
When I get a period, I check the value of the field to determine
whether there's already a period. If there is, I don't allow this
character (return false). Since the charCodes are the same in FF, the
script now disables the Delete key when there's a period in the field.
So how do I tell the difference between period and delete in Firefox?
and only one period. I also want things like delete, left/right arrow,
backspace, home, and end to work.
What I've found is that the event object is different in IE and
Firefox. In IE, I have to use the keyCode property to find out what
was pressed, in Firefox I use charCode.
But...46 is the code for period. But in Firefox's charCode property
that seems also to be the code for the "Delete" key.
When I get a period, I check the value of the field to determine
whether there's already a period. If there is, I don't allow this
character (return false). Since the charCodes are the same in FF, the
script now disables the Delete key when there's a period in the field.
So how do I tell the difference between period and delete in Firefox?