Get the App
SLTechnology News&Howtos  ›  Development  › 

How to confirm whether it is a valid keyboard input value by JavaScript

Shulou Source: shulou.com Published: 2022-06-01 02:56:38 09月22日 Update

This article is about JavaScript's ability to determine if a valid keyboard input is valid. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.

function checkKey(iKey) {

if (iKey == 32 || iKey == 229) {

return true;

} /* Spaces and exceptions */

if (iKey > 47 && iKey

< 58) { return true; } /*数字*/ if (iKey >

64 && iKey

< 91) { return true; } /*字母*/ if (iKey >

95 && iKey

< 108) { return true; } /*数字键盘1*/ if (iKey >

108 && iKey

< 112) { return true; } /*数字键盘2*/ if (iKey >

185 && iKey

< 193) { return true; } /*符号1*/ if (iKey >

218 && iKey < 223) {

return true;

} /* Symbol 2*/

return false;

Thank you for reading! About "JavaScript how to confirm whether it is a valid keyboard input value" This article is shared here, I hope the above content can have some help for everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!

Tags: Keyboard valid input numbers content more symbols articles good practical letters articles look knowledge spaces references help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MySQL Docker Shulou Information OPPO Reno