对于电台按钮:如何验证单选按钮和复选框?
$(document).ready(function() {
$('#select-number').click(function() {
if ($('input:radio', this).is(':checked')) {
return true;
} else {
alert('Please select something!');
return false;
}
});
});
没有选择单选按钮时它工作正常。但是,当我选择单选按钮并提交表单然后它也给我提示消息'Please select something!'
是否有任何好的教程可用于使用Jquery
newbie
进行验证。
你可以张贴在jsfiddle.net的完整HTML? – Chandu 2010-12-21 14:44:56
什么类型的元素是#select-number? – 2010-12-21 14:46:12