Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE: pressing enter resets form 1

Status
Not open for further replies.

gmail2

Programmer
Jun 15, 2005
987
IE
I've created a form with 2 inputs and 2 buttons. The buttons are images, and as far as I know there's no way to say <input type="submit" src="image.gif"> - you have to say <input type="image" src="image.gif">

So I've got 2 inputs saying type=image src="reset.gif" and "submit.gif". On the reset button I've looped through the form elements and reset them back to "" and said return false so that the form doesn't get submitted. For some reason when I say input type="image" it automatically acts as a submit button. This is fine with me though. However, if I fill in the fields and press enter in IE, the form doesn't get submitted, it gets reset. The reset button definitely doesn't have focus at the time as it's tabindex is higher than the submit button's tabindex. Have i setup my buttons all wrong or ... ? Can somebody help me out here?
 
Sure - use input type="reset" and then style the button to have no border, and a background image. If you do the same with your submit button (making it type="submit") then there will be no ambiguity.

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
OK I've done it for the submit button but if I don't specify a value for the button it displays Submit Query and if I specify value="" then it displays 0 (on IE6 at least). Any ideas why? Do I need to specify the font-color to match the background?
 
Sorry, I take all that back. I'm doing this remotely and the connection at the moment seems to be slow. I accidentally put "0" as the value !! Once I changed it to "" it worked fine. Thanks for that
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top