Question 57Asked in DSSSB TGT Computer Science (Technical), 13 Sep 2025, Shift 3 (5:00 PM)

How does one prevent a form from submitting when using JavaScript?

  1. Aevent.preventDefault()
  2. Bform.submit()
  3. Creturn false;
  4. Devent.stopPropagation()
Show answerHide answer

Correct answer: (A) event.preventDefault()

Explanation

Calling event.preventDefault() in the submit handler cancels the browser's default action, the form submission. stopPropagation() only stops the event from bubbling.

From DSSSB TGT Computer Science PYQ (Technical), 13 Sep 2025, Shift 3 (5:00 PM)

This is question 57 of DSSSB TGT Computer Science PYQ (Technical), 13 Sep 2025, Shift 3 (5:00 PM). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.