HTML input text 文字輸入欄位用來讓網友輸入文字
00
00
00
input Number Key only input 僅輸入數字鍵 <input type="text" onkeyup ="CT(this)"> <script> function CT(x) { var ls = x.value.substr(-1) ; if(ls.charCodeAt(0) >= 42 && ls.charCodeAt(0)<= 57){return } x.value=x.value.substr( 0,x.value.length-1 ) } < /script> input only [0 to 9] , [+ - * /]
input Number Key only input 僅輸入數字鍵 <input type="text" onkeypress ="return isNumberKey(event)" > <script> function isNumberKey(evt) { var charCode = (evt.which) ? evt.which : event.keyCode if (charCode >= 42 && charCode <= 57){return true;} if (charCode == 13){return true;} return false; } < /script> input only [0 to 9] , [+ - * /]
input on mouseove <script> var Tag= document.querySelectorAll("input") ; Tag.forEach((round) => { round.addEventListener("mouseover", function() { round.select() ; }) }) < /script>
Activate the next input field 激活下一個輸入字段 <script> var Tag= document.querySelectorAll("input") ; Tag.forEach((round) => { round.addEventListener("keypress", function(e) { if(e.key == "Enter"){ var ii = [...Tag].indexOf(event.target); if(ii > Tag.length-2){ii=-1} Tag[ii+1 ].select() } }) }) < /script>