我有2個提交按鈕的窗體上:申請jQuery的表單提交驗證到只有1出2提交按鈕
<div class="text-center">
<button type="submit" name="buttonType" value="saveSelected" id="save" class="btn btn-success">Submit</button>
<button type="submit" name="buttonType" value="declineAll" class="btn btn-danger">Decline All</button>
</div>
我最近添加了一些驗證的表單提交,但我只希望它適用於「提交」按鈕而不是「全部拒絕」按鈕。這裏是我的腳本:
$("form").submit(function(event) {
if ($('#productID').val() == '') {
$("#productID_Error").show();
event.preventDefault();
return false;
}
});
有沒有一種辦法可以限制表單驗證只有火的時候第一個提交按鈕被點擊?
哪裏是你的形式 – Mahi