62,266
社区成员
发帖
与我相关
我的任务
分享
Regex myreg = new Regex("^[0-9]+([.]{1}[0-9]+){0,1}$");
$("#divid").find(":text").each(function(){
if(myreg.IsMatch($(this).val()))
$("<span>只能填写数字</span>").insertAfter($(this));
});
<div id="div1">
<input type="text" id="t" /><span style="color:Red"></span>
<input type="text" id="x"/><span style="color:Red"></span>
<input type="button" value="按钮" onclick="fun()" />
</div>
function fun() {
$("#div1 input[type=text]").each(function () {
if ($(this).val() == "2") {//这里你改成验证是否是数字
$(this).next().text("提示信息");
}
})
}
