6

【笔记】JS阻止表单提交

 1 year ago
source link: https://feiju12138.github.io/2022/09/28/JS%E9%98%BB%E6%AD%A2%E8%A1%A8%E5%8D%95%E6%8F%90%E4%BA%A4/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

JS利用onsubmit事件阻止表单提交

阻止表单提交

<form id="form" action="#">
...
<input type="submit">
</form>
  • 如果onsubmit事件返回为true,表单会被提交;如果onsubmit事件返回为false,表单不会被提交
document.getElementId("form").onsubmit = function() {

return false;
}

哔哩哔哩——黑马程序员


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK