开发者

JavaScript "return false" from onkeypress handler

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜