function checkInteger(){
var price = document.getElementById("cprice");
if(!isNaN(price)){
cform.submit();
}else{
alert("单价必须是数字");
}
}<form name="cform" action="/hxsmelt/servlet/AddConsumables" method="post">
<input id="cprice" type="text" name="price" width="100px" />
<input type="button" name="submit" value="提交" onclick="checkInteger()"/></form>
var price = document.getElementById("cprice");
if(!isNaN(price)){
cform.submit();
}else{
alert("单价必须是数字");
}
}<form name="cform" action="/hxsmelt/servlet/AddConsumables" method="post">
<input id="cprice" type="text" name="price" width="100px" />
<input type="button" name="submit" value="提交" onclick="checkInteger()"/></form>
cform从哪来
最简单的方法你可以在你认为不执行的地方alert()第1个问题就可以alert(price);看看是什么东东
<script>
function checkInteger(){
var price = document.getElementById("cprice").value;
if(!isNaN(price)){
document.getElementById("cform").submit();
}else{
alert("单价必须是数字");
}
}
</script><form name="cform" id="cform" action="/hxsmelt/servlet/AddConsumables" method="post">
<input id="cprice" type="text" name="price" width="100" >
<input type="button" value="提交" onclick="checkInteger()">
</form>