<form action="${ pageContext.request.contextPath }/addProduct" method="post" οnsubmit="return checkform()">
商品名称:<input type="text" name="pname" id="pname"/><br/>
市场价格:<input type="text" name="market_price" /><br/>
商城价格:<input type="text" name="shop_price" /><br/>
添加时间:<input type="text" name="pdate" id="pdate"/><br/>
商品描述:<textarea rows="5" cols="15" name="pdesc"></textarea><br/>
<input type="submit" value="添加商品" />
</form>
<script type="text/javascript">
// 校验表单
function checkform(){
var pname = document.getElementById("pname").value;
if(pname == ""){
// 说明没有输入商品名称
alert("商品名称不能为空");
return false;
}
}
</script>
转载于:https://blog.51cto.com/13579086/2074307