[removed] does onsubmit only execute when it detects a “return false”

后端 未结 2 1654
难免孤独
难免孤独 2021-01-06 15:32

i dont quite understand how the onsubmit=\"return validate()\" works. why do i have to return the function? does this work only when it detects a <

2条回答
  •  孤城傲影
    2021-01-06 15:54

    When returning false, you prevent the form from being submitted. Otherwise, the form would be submitted, even though it may have validation errors, e.g., the feed value was empty.

    On the other hand, if you return true, the form data will be submitted to the URL defined by the action attribute.

提交回复
热议问题