[javascript]欄位限定只能輸入整數或是0.5為最小單位

  • 2379
  • 0
  • 2013-05-17

摘要:[javascript]欄位限定只能輸入整數或是0.5為最小單位

var diff = 10 * parseFloat(objLeavedays.value) - 10 * Math.floor(parseInt(objLeavedays.value));
            alert(parseFloat(objLeavedays.value));
            alert(Math.floor(parseFloat(objLeavedays.value)));
            alert(diff);
            if (!(diff == 4 || diff == 0)) {
                alert('超休天數的最小單位只接受0.4天!');
                objLeavedays.value = Math.floor(parseFloat(objLeavedays.value));
                objLeavedays.focus();
                return;
            }