静态页面:

<input name="marketPrice" id="marketPrice" onblur="valid()" value="${goods.marketPrice}" >

JS代码:

<script type="text/javascript">


function valid(){
var marketPrice = document.getElementById("marketPrice");

if(marketPrice.value<0){
alert("市场价格不能为负数!");
marketPrice.value="";//清空输入
marketPrice.focus();//获得焦点
}

</script>