日期:2014-05-18  浏览次数:20427 次

怎样用js遍历某一个div中的所有的<asp:TextBox>,并验证输入值是否为数字。
如何用js遍历某一个div中的所有的<asp:TextBox>,并验证输入值是否为数字。如果输入值不是数字,则在文本框的后面用红字提示“输入的不是数字”;请问各位这个怎么写啊?我用的方法达不到效果啊。

------解决方案--------------------
HTML code

 <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("提示信息");
}
})
}