[英]jquery button onclick input validation (not on form submit)
I have a form with action="autosave.php".我有一个带有 action="autosave.php" 的表单。 This saves as normal when enter is clicked or the submit button is pressed.
单击输入或按下提交按钮时,这将正常保存。
<input type="submit" id="save" value="Save Changes" />
I am also using jquery autosave, which automatically submits the form every 10 secs我也在使用 jquery 自动保存,它每 10 秒自动提交一次表单
$('form.checklist').autosave({interval:10000,......});
My problem is, i want to put jquery validation on the form, but i dont want it to validate for any any the above 3 processes.我的问题是,我想将 jquery 验证放在表单上,但我不希望它验证上述 3 个过程中的任何一个。
I only want the validation to take place when a button is clicked.我只希望在单击按钮时进行验证。
<button class="ui-state-default ui-corner-all" onclick="location.href='submit.php'" type="button">Submit</button>
Any help would be appreciated.任何帮助,将不胜感激。 Thanks in advance
提前致谢
<button id="submit" class="ui-state-default ui-corner-all" type="button">Submit</button>
<script>
$('#submit').click(function(e){
dovalidation (obviously this must be your validation function)
if(validation==true){
location.href='submit.php';
}else{
e.preventDefault; return false;
}
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.