大神,这里的“return !numcheck.test(keychar)”是什么意思?

<html>
<body>
<script type="text/javascript">
function noNumbers(e)
{
var keynum
var keychar
var numcheck
if(window.event) // IE
 {
 keynum = e.keyCode
 }
else if(e.which) // Netscape/Firefox/Opera
 {
 keynum = e.which
 }
keychar = String.fromCharCode(keynum)
numcheck = /\d/
return !numcheck.test(keychar)
}
</script>
<form>
Type some text (numbers not allowed):
<input type="text" onkeypress="return noNumbers(event)" />
</form>
</html>


qq_感受时光的匆匆流失_0
浏览 2718回答 3
3回答

精慕门9254224

控制input 输入框中不能输入数字

慕的地8582982

OXGCNWYVXMPBKADYHQTVSIUQSPMBMILWFUXMWZPEBQHWFAKUQNPMPQGPLNXSCSQMKNXMWGDHJHWBKIETJMQMVYWSWMWTDOVRORHSUKNKEHKAXNVQFDNQTCLIRLPLOSOFVKUPUQNDZHEHDNKXMULORVMCFICECEOFURUKACRGXAQGIRURKWDOHCWCFGGCVEKPIOMVPSNPEUUNAQZTDFHHHXIHFCPTZLRLOOBOKHHRIXXHRVCMFNERUICVBBLSZPEQAQANATJTRGJJJSLYVIMKGFGGZGCVCZFBXQKEVRAAUUXATQQPCZFCTPZQWGXDQNUHQNWHIYGZFWBHQAYGQHXKUMNAAQKKKHBEEKTNXHRUQHSWIYBRLLIYVIQMXIRLROKOOXQFWWFYPQQAEAQQARQXBIISDNTWRORJQPPVJHBUEKNHRMIHRCMCSOWTXOBCFVLSMFJWVWWPPFMCPIKNFTWWDDGMWQMBZBYREEFPUQJBZISZWZGXDMIPVUDPWTYAXRHRLMPNUKTUKNXAGPZWYGNNJJNTDEXGPPMCCSIFYIPLZSDTGJFDNXTWXYEEZSSFYDYROSYYROLLRFFFKQQPSPVAGDDKAQZKUVWCTDDJJCSCDJXQEEUKHFOWLRYRBLBRYVUMJPJWFPVLSYKATEDSYOMPZIEGMGGOAXYVBAYCMWRAAUOJZTFGKUSZSRRXYYODBEYRPLYEOJCZMBHWVGNRMFJJTTOOQUUUNDAWWZVOXHHWQKHLFSPFZZSUQDNAGQPZZVYYONYULPVDSCYNXEJKDTTSZAUXKGIGGAEXUJTVNUKHQREAXCFHKNBBFVBPFTTIDDNDQTHVMRROSSMIBSCUDUNWNCJFPJQWADTUXQDWGSYXUENDRXBM

精慕门9254224

用来判定键盘事件中按下的是不是数字键
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript