开发者

JavaScript "return false" from onkeypress handler

开发者 https://www.devze.com 2023-04-13 08:05 出处:网络
I used code in the below method to block my keyboard and it worked for me. <asp:textbox id=\"t1\" onkeypress=\"return false;\" />

I used code in the below method to block my keyboard and it worked for me.

<asp:textbox id="t1" onkeypress="return false;" />

Now I want to add some more for for it and I tired to do the same using extra code as

<script type="text/javascript">
fuction disablekeys()
{
return false;
}
&开发者_JAVA百科lt;/script>
<asp:textbox id="t1" onkeypress="disablekeys();" />

But this code is not working. Why?


You need to return the value returned by disablekeys:

<asp:textbox id="t1" onkeypress="return disablekeys();" />

Your new onkeypress handler currently ignores this value.

0

精彩评论

暂无评论...
验证码 换一张
取 消