MAC onkeypress problem

S

Simon Wigzell

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
 
R

RobG

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top