我有jquery表单向导,它可以从数据库中获取问题和选项。
有单选按钮。因此,在下一步之前,我要检查单选按钮是否已选中,如果没有发出警告,则无法继续下一步
我的代码在下面;
$( function() {
var $signupForm = $( '#SignupForm' );
var answer= $("#answer input[type='radio']:checked");
$signupForm.validate({
errorElement: 'em',
submitHandler: function (form) {
alert('submitted');
form.submit();
}
});
$signupForm.formToWizard({
submitButton: 'SaveAccount',
nextBtnClass: 'btn btn-primary next',
prevBtnClass: 'btn btn-default prev',
buttonTag: 'button',
validateBeforeNext: function(form, step) {
var stepIsValid = true;
var validator = form.validate();
$(':input', step).each( function(index) {
if(answer.length > 0) {
var xy = validator.element(this);
stepIsValid = stepIsValid && (typeof xy ==
'undefined' || xy);
}
});
return stepIsValid;
},
progress: function (i, count) {
$('#progress-complete').width(''+(i/count*100)+'%');
}
});
});