页面代码:
<table style="background-color:#E1EFFD;width:90%">
<tr><td>网友微博需满足:</td></tr>
<tr>
<td style="padding-left:100px;">
<input type="checkbox" name="chk_things[]" value="1"/> 已上传头像
</td>
</tr>
<tr>
<td style="padding-left:100px;">
<input type="checkbox" name="chk_things[]" value="2"/> 已绑定手机
</td>
</tr>
<tr>
<td style="padding-left:100px;">
<input type="checkbox" name="chk_things[]" value="3" /> 注册时间超过
<input type="text" id="input_reg_time" style="width:80px;" name="f_time">天
</td>
</tr>
<tr>
<td style="padding-left:100px;">
<input type="checkbox" name="chk_things[]" value="4"/> 微博数超过
<input type="text" id="input_weibo_count" style="width:80px;" name="weibo_count"/>
</td>
</tr>
<tr>
<td style="padding-left:100px;">
<input type="checkbox" name="chk_things[]" value="5"/> 粉丝数超过
<input type="text" id="input_fans_count" style="width:80px;" name="fans_count"/>
</td>
</tr>
</table>
//判断checkbox当前是否选中
var chk_faceicons = $("input[name='faceicons']").attr("checked");
if(chk_faceicons == true){
alert('选中状态,而且true不能写成“true”,因为带引号就成字符串了');
}else if(chk_faceicons == false){
alert("没有选中");
}
//把页面中的checkbox选择项拼成字符串传递过去
var checks = "";
$("input[name='chk_things[]']").each(function(){
if($(this).attr("checked") == true){
checks += $(this).val() + "|";
}
})
//验证reg_days是否输入的是数字
var reg_days = $('#rtime').val();
if(reg_days != ''){
if(!/^[-]?\d+$/.test(reg_days)){
alert("请准确输入所填项!");
return false;
}