這些都是我的窗體上的按鈕:我趕上取消單擊用php這樣取消按鈕PHP表單的jQuery
<input type="submit" id="form-submit" class="btn" name="save" value="verzenden" />
<input type="submit" name="cancel" class="btn" value="annuleren" />
:
if($_POST['cancel'])
{
Helper::redirect('page.php');
}
但在此之前提交我的形式,我使用一些jQuery來驗證表單,現在我不能點擊取消,因爲它會首先驗證。
這是我的jQuery代碼:
<script type="text/javascript">
$(document).ready(function(){
$('#cancel').delegate('','click change',function(){
console.log('test');
});
$('form').submit(function(){
var proceed = true;
$('.required').each(function(){
if ($(this).val() == '' || $(this).val() == 0 || $(this).val() == '0') {
$(this).css('border-color', '#F00');
proceed = false;
}
else {
$(this).css('border-color', '#999');
}
});
return proceed;
});
// Check on typing if a required field is empty
$('.required').keyup(function(){
if ($(this).val() == '' || $(this).val() == 0 || $(this).val() == '0')
$(this).css('border-color', '#F00');
else
$(this).css('border-color', '#999');
});
});
</script>
我怎麼能夠無視jQuery和重定向到page.php文件時,我打取消? 感謝
你爲什麼不只是使用JavaScript重定向到頁面時,點擊取消按鈕?提交一個表單只是爲了丟棄它並重定向是帶寬和時間的浪費。 – ThiefMaster
請記住,客戶端驗證是不安全的。 –
謝謝我會嘗試JavaScript重定向,並且我也有php驗證 – Ruben