开发者

Cancel key down, press, up event in PHP javascript, C#

I want to cancel out开发者_如何学运维 key press event when my textarea field gets n number of characters from user. At that point I don't want user to enter any more characters. What to do?

Edit:

I need it to be done in Javascript as well as in PHP.


In web pages, NobleCount is one possibility. Seems to be the most robust of the jQuery plugin solutions. It will give your user a count of the number of characters remaining, Twitter-style.

http://tpgblog.com/noblecount/

See also:

Interactive character limit for textarea using Jquery http://www.ajaxray.com/blog/2007/11/09/interactive-character-limit-for-textarea-using-jquery/


In Winforms, you would set Handled in the KeyPressEventArgs to true to cancel the KeyPress event. This keeps the control from processing the key press.

Note: Some controls will process certain key strokes on KeyDown. For example, RichTextBox processes the Enter key before KeyPress is called. In such cases, you cannot cancel the KeyPress event, and must cancel the key stroke from KeyDown instead.

http://msdn.microsoft.com/en-us/library/system.windows.forms.keypresseventargs.aspx

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜