views:

58

answers:

4

How can I remove focus from submit button? I don't know why it is there in the first plate, and it looks really ugly here is a screenshot :

alt text

And here is how it should look like, it regains its appearance after I click beside it and hover it.alt text

A: 

The first submit button in a form is always "in focus", hence, when you hit enter, your form gets submitted.

See responses to a similar post: http://stackoverflow.com/questions/442548/stopping-ie-from-highlighting-the-first-submit-button-in-a-form

naivists
@naivists on contrary it works fine in IE, firefox is the focusing it
c0mrade
most likely, Mozilla is trying to implement HTML5 and this is what you see. Of course, you can create a simple javascript which runs on document load event and calls `blur()` on that particular submit button. However, this sounds awkward ;-)
naivists
@naivists as much as it sounds akward it doesn't work as well, I tried it already, on several ways..
c0mrade
A: 

In your body or form...

<form onready="document.getElementById('submit').blur();">
...
<input type="submit" id="submit" />
</form>

henasraf
I already tried something similar and this as well not working m8
c0mrade
+1  A: 

Try this in your button's CSS, or that of the enclosing <a> if that's what you are using in the markup (reference):

-moz-outline:0 none;
outline:0 none;

Bear in mind that it is a valuable accessibility/keyboard feature, so ideally you would provide some alternate focus hint that is more visually pleasing to you.

bmoeskau
I'm using button not anchor tag
c0mrade
Please stop using `-moz-outline`; `outline` has been supported since Firefox 1.5.+1 for the a11y reminder.
janmoesen
Also see: http://stackoverflow.com/questions/71074/how-to-remove-firefoxs-dotted-outline-on-buttons-as-well-as-links
janmoesen
A: 

This worked :

var selectedInput = null;
$(document).ready(function() {
    $('input, textarea, select').focus(function() {
        this.blur();
    });
});
c0mrade
Note that by blurring the button on any focus you won't be able to submit the form by pressing enter on the button, which is a standard behavior most people expect. If you are worried about the visual look why not try removing the outline as I noted and leave the focus alone?
bmoeskau
@bmoeskau it doesn't work with removing element and yes I want to disable enter for submitting as well.
c0mrade