<table>
<tr>
<td><input name="textBox1" type="text" id="txt1_textBox" /></td>
<td><input name="textBox2" type="text" id="txt2_textBox" /></td>
<td><input name="textBox3" type="text" id="txt3_textBox" /></td>
</tr>
</table>
<input type="submit" name="OK" value="提交" id="OK" />我想在点击submit的时候.验证每个textbox的值是不是数字,不是数字提示"请输入数字".
要用jqery来写
<tr>
<td><input name="textBox1" type="text" id="txt1_textBox" /></td>
<td><input name="textBox2" type="text" id="txt2_textBox" /></td>
<td><input name="textBox3" type="text" id="txt3_textBox" /></td>
</tr>
</table>
<input type="submit" name="OK" value="提交" id="OK" />我想在点击submit的时候.验证每个textbox的值是不是数字,不是数字提示"请输入数字".
要用jqery来写
alert("请输入数字");
}
alert("请输入数字");
}
应该也可以
<script src="jquery.js"></script>
<table>
<tr>
<td><input name="textBox1" type="text" id="txt1_textBox" /></td>
<td><input name="textBox2" type="text" id="txt2_textBox" /></td>
<td><input name="textBox3" type="text" id="txt3_textBox" /></td>
</tr>
</table>
<input type="submit" name="OK" value="提交" id="OK" onclick="return wsp();"/>
<script>
function wsp()
{
$("input[type='text']").each(function(){
if($(this).val()=="")
{
alert("请将数据填写完整!");
$(this).focus();
return false;
}
})
}</script>
//是要验证数字啊,上面看错了。<script src="jquery.js"></script>
<table>
<tr>
<td><input name="textBox1" type="text" id="txt1_textBox" /></td>
<td><input name="textBox2" type="text" id="txt2_textBox" /></td>
<td><input name="textBox3" type="text" id="txt3_textBox" /></td>
</tr>
</table>
<input type="submit" name="OK" value="提交" id="OK" onclick="return wsp();"/>
<script>
function wsp()
{
$("input[type='text']").each(function(){
if($(this).val()!="")
{
var part=/^[1-9]\d{0,8}(\.\d{1,2})?|0(\.\d{1,2})?$/;
if(!part.test($(this).val()))
{
alert("请填写正确数据格式(如:整数位0-9位,小数位1-2位)!");
$(this).focus();
$(this).select();
return false;
}
}
})
}</script>
<script src="jquery.js"></script>
<table>
<tr>
<td><input name="textBox1" type="text" id="txt1_textBox" /></td>
<td><input name="textBox2" type="text" id="txt2_textBox" /></td>
<td><input name="textBox3" type="text" id="txt3_textBox" /></td>
</tr>
</table>
<input type="submit" name="OK" value="提交" id="OK" onclick="return wsp();"/>
<script>
function wsp()
{
$(":text").each(function(){
if(isNaN($(this).val()))
{
alert("非数字!");
$(this).focus();
return false;
}
})
}</script>