對“價格”數字的一段JS控制

<script>
function submitPrice(){
var minPrice=document.priceFrm.minPrice.value;
var maxPrice=document.priceFrm.maxPrice.value;
regexpdat= /^/d+(/./d{1,2})?$/;
if(!regexpdat.test(minPrice)||!regexpdat.test(maxPrice)){
 alert('輸入的價格必須爲合法數字,並且最多兩位小數');
 return false;
}
if(parseFloat(minPrice)>=parseFloat(maxPrice)){
alert('輸入的價格範圍不正確');
return false;
}
if((parseInt(maxPrice)+"").length>8||(parseInt(minPrice)+"").length>8){
alert('輸入的價格數值太大');

return false;
}
  window.location.href='${help.codeUrl2(4)}price=' + document.priceFrm.minPrice.value + 'AA' + document.priceFrm.maxPrice.value;
  return true;
}
</script>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章