我有一个表格,在一些价值观审查后写下更改。在routes.py
中,我确保通过.validate_on_submit()
验证表单:
### ... rest of routes.py ....
form = VariantOverallRevision()
if form.validate_on_submit() :
### ... code to write new class on file ...
flash("sent!")
### ... rest of routes.py ....
我想在此提交中通过js
插入一个是/否确认按钮,但我不知道如何在单击后集成“提交停止”
我设法在button元素中集成了一个confirm()
,但是很显然,只要单击按钮,表单就会被发送(而不是在调用jsconfirm()
之后):
function confirm_ACMG_review()
{
confirm("Save data?");
}
if (confirm_ACMG_review) {
//proceed to sumbmission
}
else {
//block submission
}
document.getElementById('manual_ACMG_annotation_confirm_review').onclick = confirm_ACMG_review;
这里是HTML
部分:
<form id="manual_ACMG_annotation_confirm_form" action="" method="post" novalidate>
{{ form.hidden_tag() }}
{{ form.submit( id = "manual_ACMG_annotation_confirm_review", style = "font-size: 120%; font-weight: bold;" ) }}
</form>
我知道我可以打开一个不同的页面/重定向到其他URL等,但我想知道是否有任何方法可以使用js整合flask提交
提前非常感谢您的帮助
您可以在单击事件时使用
preventDefault()
方法,以便默认情况下不提交表单相关问题 更多 >
编程相关推荐