--javascript代码
function checkForm(){
var aaa = document.getElementsByName("newnum");
var hasNull = false;
var re = /^[0-9]+.?[0-9]*$/;
for(i=0;i<aaa.length;i++){
if(!(aaa[i].value) || !re.test(aaa[i].value))
hasNull = true;
}
if(hasNull) {
alert('请输入数字,且不能为空'+aaa.length);
return false;
}
}
--jsp代码
<form action="jsp2" method="post" name="from1">
<table>
<tr>
<td> <input type="text" name="test1" value="1"/> <td>
</tr>
<tr>
<td> <input type="submit" name="Submit1" οnclick="return checkForm();" value="修改数量" /> </td>
</tr>
</table>
</from>