简体   繁体   中英

Input type only with numbers

我制作了仅适用于数字的表格,当用户键入无效的字母时,我想提醒用户,然后删除该容灾或将输入框设为红色...,我该怎么做?

Don't let the user type anything else, if you dont want to.

You can observe the onkeypress-Event and check the charCode. If it's not a Number, simply return false .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM