首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

怎样用js遍历某一个div中的所有的<asp:TextBox>并验证输入值是否为数字。该如何解决

2012-04-10 
怎样用js遍历某一个div中的所有的asp:TextBox,并验证输入值是否为数字。如何用js遍历某一个div中的所有的

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

热点排行