例如:
<input id="name" type="text" onkeydown="if(event.keyCode != 48) return false;" ></input>
此时除了0,其他数字均无法输入
但是改写成下面的形式却不行
<head> <mce:script type="text/javascript"><!-- function test(event){ if(event.keyCode != 48) return false; } // --></mce:script> </head> <body> <input id="name" type="text" onkeydown="test(event)" ></input> </body>
如果写成下面的形式,也能达到控制的目的
<head> <mce:script type="text/javascript"><!-- function test(event){ if(event.keyCode != 48) event.returnValue = false; } // --></mce:script> </head> <body> <input id="name" type="text" onkeydown="test(event)" ></input> </body>
370

被折叠的 条评论
为什么被折叠?



