Simon Wigzell said on 14/03/2006 4:51 AM AEST:
I have a simple function whose purpose is to return false onkeypress and
then that character should not appear in the text field.
On any browser I have tried on a PC the return false means that the key
pressed character won't appear in the text field. On a MAC with Safari it
will. Any idea how I can prevent the character from appearing in the text
box for MAC Safari? This link is to a stripped down version that
demonstrates the problem:
http://www.dynamicwebsitesystems.com/test.htm
Don't use 'return false'.
What you are trying suggests that you want to look at keycodes and
prevent presses of certain keys. That strategy is nearly always doomed
to failure - it is much better to look at the actual text entered and
advise where it differs from what you want.
Remember that sniffing keypresses doesn't restrict what a user can enter
into the field - there are a couple of ways to enter any value I like
into your field even in browsers where 'return false' prevents
keypresses. And if scripting is disabled or not available, your script
can't do anything.
--
Rob