• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

inputTextArea limit characters

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have got an <h:inputTextarea
id="looking" cols="30" rows= "2"
value="#{LookingPage.lookingDetails}"
required="false"
onkeyup="this.value = this.value.substring(0, 100);" >
</h:inputTextarea>

I want to try and limit the number of characters entered, this is working fine with the onkeyup="this.value = this.value.substring(0, 100);" , the issue is if I try to edit any character it jumps to after the last existing character...any idea as to how to resolve this?

Thanks
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Maybe this will help you:

Limit textarea with countdown

Kind regards,

Carlos Ferreira
 
Mary Joe
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This following resolved my issue


<t:inputTextarea value="#{testBean.testString}"
onkeyup="limitTextArea(this,100);"
onkeydown="limitTextArea(this,100);"
cols="30"
rows="2" />

<script>
function limitTextArea(element, limit) {

if (element.value.length > limit) {
element.value = element.value.substring(0, limit);
}

}

</script>

reply
    Bookmark Topic Watch Topic
  • New Topic