【发布时间】:2014-11-22 15:05:15
【问题描述】:
我正在尝试制作一个 Jquery 简单函数,并且只想在单选按钮值为“1”时提交表单。如果不是,请不要提交表单并更改一些内容,如下面的代码所示。
目前,如果单选按钮的值为“1”或“0”,则表单无论如何都会提交。
<script>
$(document).ready(function() {
$('.result').hide();
$('input.prettycheckbox').prettyCheckable({});
$('input.submit').on('click', function(e) {
e.preventDefault();
$('input.prettycheckbox').each(function(){
if ($(this).is(':checked') && $(this).is('input[value="0"]')) {
$(this).attr("disabled", true);;
$('.result').show();
$('.advise').hide();
$(this).parent().parent().addClass('incorrect');
} else {
$('form').submit();
};
});
});
});
</script>
非常感谢!
【问题讨论】:
标签: jquery button onclick submit radio