我有以下代碼。檢查表單是否成功提交html5
<div class="form-group">
<label for="store_account_name">Store Title</label>
<input type="text" value="" class="form-control" name="store_account_name" id="store_account_name" placeholder="Please insert store title of the external store" required />
</div>
<div class="form-group">
<label for="store_url">Store URL</label>
<input type="url" value="" class="form-control" name="store_url" id="store_url" placeholder="Please insert store URL as described in help section" required />
</div>
關於提交按鈕我想檢查表單是否經過驗證。我有一個listner事件,它具有preventDefault按鈕。所以我只想在這兩個輸入都被成功驗證的時候發送ajax調用。是否有任何JS函數來檢查驗證的狀態或任何CSS屬性添加到無效字段。
請澄清更多。 – halkujabra
現在當表單被提交時,即使字段未被驗證,也會進行ajax調用。只有在字段驗證成功後才能進行Ajax調用。 –
請更改標題。你需要這樣的東西:'在表單提交中添加事件偵聽器'。您絕對不需要檢查表單是否已提交。 – FreeLightman