Posted At : Jun 29, 2010 16:23 PM
| Posted By : Ed Tabara
Related Categories:
Other
What the action of the
BUTTON tag would be when used in a form? I don't use it often (or better to say do it very rare), but by some reason, maybe from the old days when mostly been using IE, was considering that clicking it in a form would have no effect till the
ONCLICK would be defined. But it wasn't the case. To better understand what i mean, try the following code:
<form name="frm" action="" method="post" onsubmit="return validate()">
Email: <input class="form" type="text" size="36" name="email" id="email" value=""><br>
<input type="submit" class="form1" value=" Invite ">
<button class="form1" onclick="window.location='?a=1';"> Invite Later </button>
</form>
<script language="JavaScript" type="text/javascript">
function validate()
{
alert('1');
return true;
}
</script>
It appears that it has a
TYPE attribute that has a different default value for different browsers. The default type for
Internet Explorer is
BUTTON, while in other browsers (and in the W3C specification) it is
SUBMIT.
A couple o additional notes...
- In the above code, you may have the BUTTON tag behave as TYPE="BUTTON" also by adding return=false; in the ONCLICK at the end.
- If you use the button element in an HTML form, different browsers will submit different values. Internet Explorer will submit the text between the <button> and </button> tags, while other browsers will submit the content of the VALUE attribute.
Comments (0) |
Print |
Send
| 360 Views
| 2% / 0% Popularity