javaScript 确认验证框
<script type="text/javaScript">
function deleteitem() {
var b = window.confirm("你确认归零吗?");
if (b) {
//window.location.href = "#"
window.location.reload();
//window.location.href = "${pageContext.request.contextPath}/servlet地址"
}
}
function changeQuantity(input){
var quantity = input.value;
var oldvalue = document.getElementById("oldvalue");
if(quantity!=parseInt(quantity) || quantity <0){
alert("请输入正整数!!");
input.value = oldvalue.value;
return;
}
oldvalue.value = input.value;
//window.location.href = "${pageContext.request.contextPath}/servlet地址"
alert("修改成功");
}
</script>
</head>
<body>
<input type="text" value="0" hidden="hidden" id="oldvalue">
<input id="test" type="text" value="0" onchange="changeQuantity(this)">
<a href="javascript:void(0)" onclick="deleteitem()">归零</a>
</body>