js阻止表单重复提交

时间:2023-03-08 18:00:11
//校验表单的数据
function newFatherModuleVerify()
{
var moduelName = $('#fatherModule_moduelName').val();
alert(moduelName);
return false;
}
        <form:form commandName="fatherModule" action="saveFatherModule" onsubmit="return newFatherModuleVerify();" method="post">
<table class="au">
<tr>
<td>版块名称</td>
<td><form:input id='fatherModule_moduelName' path="moduelName"/></td>
<td>支持HTML代码</td>
</tr>
<tr>
<td>排序</td>
<td><form:input id='fatherModule_sort' path="sort"/></td>
<td>支持HTML代码</td>
</tr>
</table>
<input class="btn" style="cursor: pointer; margin-top: 10px"
type="submit" name="submit" value="添加">
</form:form>

关键在于要加上return

onsubmit="return newFatherModuleVerify();"