Nomi Ali
Nomi Ali

Reputation: 2262

Textbox user input restriction

I use onkeypress="return this.value.length" that working fine. but i do copy and paste it keep on putting data in the text box. it should work for copy-paste operation too.

what i need to do for copy-paste operation to work for that too!

Upvotes: 0

Views: 890

Answers (4)

jason
jason

Reputation: 3615

If you are looking for a way to limit what characters can be entered into a text box, you may find that the AjaxControlToolKit can help. It has a control called Filtered Textbox contro. Take a look at http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/FilteredTextBox/FilteredTextBox.aspx

Upvotes: 1

Millenjo
Millenjo

Reputation: 441

I think ontextchanged="" could cover it

Upvotes: 0

Gaurav
Gaurav

Reputation: 1098

Use below code to find length while typing

<input type="text" onkeyup="alert(this.value.length)" / >

Hope it helps !! :)

Upvotes: 1

Parv Sharma
Parv Sharma

Reputation: 12705

use onchange with onkeypress. so that whatever you have put there also executes on change

Upvotes: 0

Related Questions