Weird Safari Bug
posted on october 7, 2003, tag: software
While working today I found a very strange Safari bug. On an order form I was creating, a user must keep a checkbox checked, otherwise they can't submit the order. To facilitate this, I used a simple line of JavaScript. In the onclick attribute of the checkbox, I call a JS function called ableButton() that looks like this:
function ableButton() {
if (document.order.go_order.checked==true) {
document.order.submit.disabled = false;
} else {
document.order.submit.disabled = true;
}
}
Now, that works fine (in all modern browsers), and, if the browser supports it (most do), grays out the submit button. This works just fine in Safari. The bug is something else: if you click on the disabled submit button, it does nothing. As it should. But! If you double-click the button, it submits!
It's almost as if Safari believes disabling means, "don't let them use it, unless they seem like they really want to." I tested this in all the other browsers I have, and Safari was the only one that it worked in. Strange.
Comments
There are 2 comments, comments are closed
Paul Griffiths on 10/18/2003:
This is also the same for password inputs in safari. If you try and add the disabled attribute to a password input, Safari still allows the user to enter a password in!
gui weinmann on 07/20/2004:
Interesting comments.
I'm think I may have found another problem with Safari - it seems like any other flavor of javascript allows one to programatically assign the value of a checkbox.
But not Safari.
function resetFormButtons(theForm) {
counter=theForm.elements.length;
for (i = 0; i<counter; i++) {
theForm.elements[i].value='foo';
// this actually does nothing in safari but works in all other browsers (ie, opera, netscape, mozilla, etc)
}
}