Re: [請益] 表單文字方塊
※ 引述《gckenny (絕体絕命!小君君的最期~)》之銘言:
: <script type="text/javascript">
: function check_num()
: {
: if ((/\D/.test(document.getElementById('num').value)) ||
: ((document.getElementById('num').value).length > 1))
: {
: alert("請輸入單一數字!");
: document.getElementById('num').focus();
: return false;
: }
: }
: </script>
: <input type="text" id="num" onblur="check_num()" />
可是若使用者輸入的是一個字母(a-z)怎麼辦呢?它的lendth不也是1嗎?原問不是只要
使用者輸入1個數字嗎?
觀念有誤請指教...
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.138.74.203
推
01/11 18:00, , 1F
01/11 18:00, 1F
推
01/11 18:50, , 2F
01/11 18:50, 2F
討論串 (同標題文章)
PHP 近期熱門文章
PTT數位生活區 即時熱門文章