Well I am trying to submit a form by pressing enter but not displaying a submit button. I don't want to get into JavaScript if possible since I want everything to work on all browsers (the only JS way I know is with events).
Right now the form looks like this:
<form name="loginBox" target="#here" method="post">
<input name="username" type="text" /><br />
<input name="password" type="password" />
<input type="submit" style="height: 0px; width: 0px; border: none; padding: 0px;" hidefocus="true" />
</form>
Which works pretty well. The submit button works when the user presses enter, and the button doesn't show in Firefox, IE, Safari, Opera and Chrome. However, I still don't like the solution since it is hard to know whether it will work on all platforms with all browsers.
Can anyone suggest a better method? Or is this about as good as it gets?
You could try also this
You could include an image with width/height = 0 px
This is my solution, tested in Chrome, Firefox 6 and IE7+:
Instead of the hack you currently use to hide the button, it would be much simpler to set
visibility: collapse;
in the style attribute. However, I would still recommend using a bit of simple Javascript to submit the form. As far as I understand, support for such things is ubiquitous nowadays.the simplest way
The most elegant way of doing this is to keep the submit-button, but set it's border, padding and font-size to 0.
This will make the button dimensions 0x0.
You can try this yourself, and by setting an outline to the element you will see a dot, which is the outside border "surrounding" the 0x0 px element.
No need for visibility:hidden, but if it makes you sleep at night, you can throw that in the mix as well.
JS Fiddle
I think you should go the Javascript route, or at least I would: