Microsoft KB Archive/828907

= The form is submitted when you press ENTER on a Form page in SharePoint Designer 2007 or in FrontPage 2003 =

Article ID: 828907

Article Last Modified on 5/30/2007

-

APPLIES TO


 * Microsoft Office SharePoint Designer 2007
 * Microsoft Office FrontPage 2003

-





For a Microsoft FrontPage 2002 version of this article, see 302905.



For a Microsoft FrontPage 2000 version of this article, see 292760.



SYMPTOMS
You type information in a form on a Web page, and then you press ENTER on the keyboard. When you do this, the form is submitted instead of the insertion point moving to the next form field.



CAUSE
This behavior occurs because the default behavior for a Web browser is to submit the form when you press ENTER.



WORKAROUND
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. Note You may receive an error message if you copy the examples directly from this article and paste them into FrontPage. The angle brackets may appear as escaped HTML code. To work around this behavior, paste the script into a blank Notepad document, and then copy it from Notepad before you paste it into FrontPage.

To work around this behavior, use Dynamic HTML (DHTML) to intercept the ENTER keystroke and convert it to a TAB keystroke. To do this, follow these steps, as appropriate for the product that you are using.

Microsoft Office SharePoint Designer 2007
Important The following sample code uses custom DHTML that may not be available in all browsers.  Open a Web in SharePoint Designer 2007, and then create a new page. Insert a form on the page. To do this, follow these steps:  In the Toolbox pane, right-click Form underForm Controls, and then click Insert. Right-click the form, and then click Form Properties. In the Form Name box, type myForm .</li> Click OK.</li></ol> </li> Add two Text Area boxes to the form. To do this, follow these steps: <ol style="list-style-type: lower-alpha;"> In the Toolbox pane, right-click Text Area underForm Controls, and then click Insert.</li> Position the insertion point to the right of the Text Area box, and then press ENTER.</li> In the Toolbox pane, right-click Text Area underForm Controls, and then click Insert.</li></ol>

You should now have two Text Area boxes, one under the other.</li> Delete the Submit button and the Reset button.</li> Switch to Code view, and then make the following changes: <ol style="list-style-type: lower-alpha;">  Locate the tag, and then change it to the following tag: <body onContextMenu=&quot;return false&quot; onKeyDown=&quot;if (window.event.keyCode==13) window.event.keyCode=9;&quot;> </li>  Locate the tag, and then change it to the following tag: <input onKeyDown=&quot;if (window.event.keyCode==13) myForm.submit;&quot; type=&quot;submit&quot; value=&quot;Submit&quot;/>

<input onKeyDown=&quot;if (window.event.keyCode==13) resetForm;&quot; onClick=&quot;resetForm;&quot; type=&quot;button&quot; value=&quot;Reset&quot;/>

<script language=&quot;JavaScript&quot;>

</li></ol> </li> Save the page as Formtest.htm in your Web.</li></ol>

When you view this page in Microsoft Internet Explorer and then press ENTER, the page is captured and converted to a TAB keystroke. This occurs unless you press the ENTER key when either the Submit button or the Reset button has focus.

Microsoft Office FrontPage 2003
Important The following sample code uses custom DHTML that may not be available in all browsers. <ol> Open a Web in FrontPage 2003, and then create a new page.</li> Insert a form on the page. To do this, follow these steps: <ol style="list-style-type: lower-alpha;"> On the Insert menu, point to Form, and then click Form.</li> Right-click the form, and then click Form Properties.</li> In the Form Name box, type myForm .</li> Click OK.</li></ol> </li> <li>Add two text boxes to the form. To do this, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>On the Insert menu, point to Form, and then click Textbox.</li> <li>Press ENTER.</li> <li>On the Insert menu, point to Form, and then click Textbox.</li></ol> </li> <li>Delete the Submit button and the Reset button.</li> <li>Switch to Code view, and then make the following changes: <ol style="list-style-type: lower-alpha;"> <li> Locate the tag, and then change it to the following tag: <body onContextMenu=&quot;return false&quot; onKeyDown=&quot;if (window.event.keyCode==13) window.event.keyCode=9;&quot;> </li> <li> Locate the tag, and then change it to the following tag: <input onKeyDown=&quot;if (window.event.keyCode==13) myForm.submit;&quot; type=&quot;submit&quot; value=&quot;Submit&quot;>

<input onKeyDown=&quot;if (window.event.keyCode==13) resetForm;&quot; onClick=&quot;resetForm;&quot; type=&quot;button&quot; value=&quot;Reset&quot;>

<script language=&quot;JavaScript&quot;>

</li></ol> </li> <li>Save the page as Formtest.htm in your Web.</li></ol>

When you view this page in Microsoft Internet Explorer and then press ENTER, the page is captured and converted to a TAB keystroke. This occurs unless you press the ENTER key when either the Submit button or the Reset button has focus.

<div class="status_section">

STATUS
This behavior is by design.

Additional query words: kbnoOfficeAlertID prb fp2003 spd2007

Keywords: kbforms kbprogramming kbinfo KB828907

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.