IE firing submit on button even there is no tag
I know that if we've a <form> and an <input> with or without submit
button, on pressing Enter key will submit that enclosing form. But, IE is
submitting (specifically, clicking the first button it encounters) even
when there is no <form> tag present.
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<button onclick="alert('button 1 clicked')">button 1</button>
<button onclick="alert('button 2 clicked')">button 2</button>
<input type="text" />
</body>
</html>
When 'Enter' is pressed with in input field, 'button 1 clicked' alert will
be seen.
If I surround <input> with a <form> tag, it is not submitting.
This behavior is observed in IE9 and IE 10 too (haven't tested other
versions). Is this a bug in IE or if it is not, how to stop this
happening?
No comments:
Post a Comment