Re: JavaScript Question

  • From: niran <public.niran@xxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Wed, 22 Jul 2009 18:30:33 +0530

Hi,
Few months ago I wrote a blog post on this issue and how I implemented this feature.
http://www.nirandas.com/post/max-length-property-for-textarea.aspx
Main difference is that instead of not allowing key down/key up on textarea if the size exceeds, it removes the extra chars from the text.

txt.value = txt.value.substr( 0, size);

HTH

--
My website is at
http://nirandas.com
BlindAdrenaline.com have released Card Games for blinds!
http://blindadrenaline.com/cardroom/


RicksPlace wrote:
Hi: I have the following code to check the TextArea to make sure a user doesn't enter more than 10 characters. It works but badly with a screen reader. If I enter 11 characters it will keep typing but no more characters are added to the box. Then when I try to open it again I just hear a ping with left and right cursor. Up and Down cursor reads the 10 characters but I can't delete anything using the delete key, I am locked out of the box. How do you JS folks handle a MaxLength situation that works well with screen readers? Here is the code I am currently using.It took some work to get it working but I am not happy with the way it reads for screen reader users. Overview: <textarea name="ctl00$MainStarTrekContent$FormView1$OverviewTextBox" rows="10" cols="20" id="ctl00_MainStarTrekContent_FormView1_OverviewTextBox" onkeydown="if(this.value.length>=10) return false;" onkeyup="if(this.value.length>=10) return false;" style="width:800px;">abc</textarea>
  <br />
Note: These are bound TextBoxes inside a MS ASP.net FormView if that colors your solution.
Thanks for any Ideas:
Rick USA


__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: