This is the default behavior for most fields except text areas.
To get around this, you can call the javascript function before submitting the form to check for keystrokes.
<script type="text/javascript">
function allowSubmission() {
return !(window.event && window.event.keyCode == 13); }
</script>
Then the only way to submit the form is to actually click submit. However, as many people mentioned, the input key representing the form is the expected behavior, so you can always change the function to perform basic validation in the fields, allowing you to enter the key to submit the form if all the required fields are filled.
<script type="text/javascript">
function allowSubmission() {
return !(window.event && window.event.keyCode == 13) || validateInput(); }
</script>
Edit: You called this function using the OnClientClick method of your submit button. Sort of:
<asp:Button id="SubmitBtn" runat="server" OnClientClick="return allowSubmission()"/>
source
share