Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize that text boxes can only enter numbers in html

Shulou Source: shulou.com Published: 2022-06-03 11:00:12 11月15日 Update

Editor to share with you how to achieve html text box can only enter numbers, I hope you have something to gain after reading this article, let's discuss it together!

1. Write onkeypress= "if (event.keyCode) directly in the text field.

< 45 || event.keyCode >

57) event.returnValue = false; "

2. Write another function

Var str= "0123456789"; function press () {var str1=document.all.fundsname.value; for (int iTuno; I)

Tags: Input number text form article Chinese information function character string finished integer more knowledge industry information information channel channel local field Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Tech Info Xiaomi MariaDB NVidia