Multiple choice general knowledge

Consider an HTML form with a checkbox and a text field. When data is entered and the return key is pressed, the data seems to be lost before the user can click on the button that calls the processing function. How do you correct this?

  1. Add a TYPE=HIDDEN INPUT to the form

  2. Trap the return keypress and return (null)

  3. Add 'return false' to onsubmit="..." in the FORM tag

  4. Instruct the user not to press the Return key.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Adding 'return false' to the onsubmit handler in the FORM tag prevents the default form submission behavior when the user presses Enter. This allows custom JavaScript processing to handle the form data instead. The other options - hidden input, trapping return key, or instructing users - don't address the core issue of form submission behavior.