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.
精彩评论