The form is submitted when you press ENTER on a Form page in FrontPage 2003 (828907)



The information in this article applies to:

  • 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

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

CAUSE

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 (<and>) may appear as escaped HTML code (<and>). 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.

Important The following sample code uses custom DHTML that may not be available in all browsers.

For more information about compatibility with other browsers, click Microsoft FrontPage Help on the Help menu, type compatibility in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
  1. Open a Web in Microsoft Office FrontPage 2003 and create a new page.
  2. Insert a form on the page. To do so, follow these steps:
    1. On the Insert menu, point to Form, and then click Form.
    2. Right-click the form, and then click Form Properties.
    3. In the Form Name box, type myForm.
    4. Click OK.
  3. Add two text boxes to the form. To do so, follow these steps:
    1. On the Insert menu, point to Form, and then click Textbox.
    2. Press ENTER.
    3. On the Insert menu, point to Form, and then click Textbox.
  4. Delete the Submit button and the Reset button.
  5. Switch to Code view and make the following changes:
    1. Locate the <body> tag and change it to the following:
       <body onContextMenu="return false" onKeyDown="if (window.event.keyCode==13) window.event.keyCode=9;">
      						
      
    2. Locate the </form> tag and change it to the following:
      <!-- show a SUBMIT button -->
      <input onKeyDown="if (window.event.keyCode==13) myForm.submit();" type="submit" value="Submit"><br>
      
      <!-- show a RESET button -->
      <input onKeyDown="if (window.event.keyCode==13) resetForm();" onClick="resetForm();" type="button" value="Reset"><br>
      
      <!-- DHTML script to reset the form -->
      <script language="JavaScript">
      <!--
      // Set the focus of the form to the first element.
      myForm.elements(1).focus();
      function resetForm()
      {
      // Prompt to reset the form.
      if (confirm('Are you sure you want to clear the form?'))
      window.location.reload(); // Reload the page to clear the form.
      }
      //-->
      </script>
      
      </form>
      
      
  6. Save the page as Formtest.htm in your Web.
When you view this page in Microsoft Internet Explorer and press ENTER, it will be captured and converted to a TAB keystroke unless you press the ENTER key when either the Submit or Reset buttons have focus.

STATUS

This behavior is by design.

Modification Type:MinorLast Reviewed:1/6/2006
Keywords:kbForms kbProgramming kbinfo KB828907 kbAudEndUser