Discussion Forums - Forums for discussion of accessible web site design
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister  Content Enhanced - Use Any Browser
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Posts to this forum are now disabled due to low use and abuse by spammers.

Limiting textarea size in Safari

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Any Browser Forums Forum Index -> Browser Issues
View previous topic :: View next topic  
Author Message
larrykluger



Joined: 01 Nov 2007
Posts: 2

PostPosted: Thu Nov 01, 2007 3:34 pm    Post subject: Limiting textarea size in Safari Reply with quote

Hi All!

I want to stop people from entering more than X characters into a textarea field.

The following works great in IE and FF. But not in Safari. Any thoughts? Or other suggested forums?

-- In Safari, the span with the current total works correctly. But after reaching the limit, the user can still add to the textarea. In IE and FF, additional data entry is ignored (correct behavior).

Thanks much,

Larry
Code:

<script type='text/javascript'>
<!--
// From http://www.mediacollege.com/internet/javascript/form/limit-characters.html
function limitText(limitId, countId, limitNum) {
   var limitedField = document.getElementById(limitId);
   var countField = document.getElementById(countId);
   
   function limitedTextColor(red) {
     countField.style.color = red ? 'red':'black';
     document.getElementById(countId+'0').style.color = red ? 'red':'black';
     document.getElementById(countId+'1').style.color = red ? 'red':'black';
   }
   
   if (limitedField.value.length > limitNum) {
      limitedField.value = limitedField.value.substring(0, limitNum);
      countField.innerHTML = '0';
      limitedTextColor(true);
   } else {
      countField.innerHTML = (limitNum - limitedField.value.length)+'';
      limitedTextColor( (limitedField.value.length / limitNum ) > .9);
   }
}
//-->
</script>

/////////////////////////////////////////////////

<textarea cols='40' id='bio' name='conference_user[proposed_bio]' rows='20'
onKeyDown="limitText('bio','bio_countdown',400);" onKeyUp="limitText('bio','bio_countdown',400);">
</textarea>
<br />
<span id='bio_countdown0'>Maximum 400 characters.  You have </span>
<span id='bio_countdown'></span>
<span id='bio_countdown1'>characters left.</span>

Back to top
View user's profile Send private message
Adrian



Joined: 04 Jun 2007
Posts: 52

PostPosted: Thu Nov 01, 2007 11:55 pm    Post subject: Re: Limiting textarea size in Safari Reply with quote

larrykluger wrote:
Hi All!

I want to stop people from entering more than X characters into a textarea field.

The following works great in IE and FF. But not in Safari. Any thoughts? Or other suggested forums?

-- In Safari, the span with the current total works correctly. But after reaching the limit, the user can still add to the textarea. In IE and FF, additional data entry is ignored (correct behavior).

Thanks much,

Larry



This maybe work, although I've not tried it.

http://www.mediacollege.com/internet/javascript/form/limit-characters.html
_________________
Adrian

Rayfields accessibility consultancy - Independent Testers - Breakofday
Back to top
View user's profile Send private message Visit poster's website
larrykluger



Joined: 01 Nov 2007
Posts: 2

PostPosted: Fri Nov 02, 2007 5:48 am    Post subject: Reply with quote

Hmmm, Thanks Adrian.

That example does indeed work in Safari. So I'll try to figure out what I'm doing differently, seeing as how my code was based on the Media College example.

Regards,

Larry
Back to top
View user's profile Send private message
Adrian



Joined: 04 Jun 2007
Posts: 52

PostPosted: Fri Nov 02, 2007 11:18 am    Post subject: Reply with quote

larrykluger wrote:
Hmmm, Thanks Adrian.

That example does indeed work in Safari. So I'll try to figure out what I'm doing differently, seeing as how my code was based on the Media College example.

Regards,

Larry


Hope you manage to figure it out.
_________________
Adrian

Rayfields accessibility consultancy - Independent Testers - Breakofday
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Any Browser Forums Forum Index -> Browser Issues All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
This board is protected by Phpbbantispam
Powered by phpBB © 2001, 2005 phpBB Group