I’ve just noticed something that I’d never noticed before, while working on a (regular, no-JS) form.
If the form is submitted by clicking on the Submit button, it sends the Submit button data (&submit=Submit or some such).
However, the same form omits the Submit button data when submitted with the Enter key.
Example form:
<div id="messagebox">
<?php
echo 'txt: [' . $_REQUEST['txt'] . ']<br>';
echo 'submit_btn: [' . $_REQUEST['submit_btn'] . ']<br>';
?>
</div>
<hr>
<div id="formbox">
<form method="POST" action="?">
<input type="text" name="txt" id="txt" value=""><br>
<input type="submit" name="submit_btn" id="submit_btn" value="Submit"><br>
</form>
</div>
[It should display both variables when a form is submitted, but it omits the Submit button data when Enter is pressed.]
I’ve been using the presence of the submit POST variable to do a server-side check. I guess I’m going to have to add a hidden input or something.
Anyway, the question: Is this normal behaviour? If so, why?
I’d assumed that the Enter key simply mimicked the Submit button. I’m now guessing it doesn’t. If the Submit button is part of the form but just happened not to be clicked, why is it not sent with the rest of the data?
With enter key the form submission happens correctly . But in IE7 , submit button value will be missing , strange behavior. So you can check whether form submitted or not , by using a hidden text field with fixed text in that . Thanks