🎴 Flashcard Mode
JavaScript Fundamentals Quiz
Card1 / 15
Mastered0
Review0
QuestionClick to flip
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?
AnswerClick to flip back
A
Add 'return false' to onsubmit="..." in the FORM tag
💡 Explanation:
The issue is that pressing Return in a text field within a form submits the form prematurely, before the user can click the processing button. The correct solution is to add 'return false' to the onsubmit handler in the FORM tag, which prevents the default form submission behavior. Option A (hidden input) doesn't address the issue. Option B (trapping return key) is incomplete. Option D (user instruction) is not a technical solution.