disabling enter key on submit

Results 1 to 2 of 2

Thread: disabling enter key on submit

  1. #1
    Join Date
    Dec 1969

    Default disabling enter key on submit

    How can I disable a form from submitting when someone presses the Enter key but sends the form when the Submit button is clicked? I tried the following:<BR><BR>&#060;form name="frmAdd" method="POST" onSubmit="return false" runat="server"&#062;<BR>...<BR>...<BR>&#060;asp:bu tton id="btnSubmit" text="Submit" onClick="btnSubmit_Click" runat="server" /&#062; (uses codebehind)<BR><BR>This just disables submitting the form altogether even when I click on the button.<BR><BR>Thanks!

  2. #2
    Join Date
    Dec 1969

    Default RE: disabling enter key on submit

    What you can do is disable caching. Not tested but try something like...<BR><BR>Response.Buffer = True<BR>Response.ExpiresAbsolute = Now() - 1<BR>Response.Expires = 0<BR>Response.CacheControl = "no-cache"<BR><BR>Or maybe with Javascript...<BR><BR>put this in the If/Then Page.IsPostBack block of the page_load: <BR><BR>button1.attributes.add("onclick", "javascript:{this.style.display = \"none\";}");

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts