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 dont want user to enter any more characters. What to do?

Edit:

I need it to be done in javascript as well as in php

Answers


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


Need Your Help

linear programming in python?

python linear linear-programming

I need to make a linear programming model. Here are the inequalities I'm using (for example):