Character limit for text field

I was just wondering if there is a way to limit the number of characters
that can be entered in a textfield? Here is what I have for a helper:

<%= text_area ‘user’, ‘rentalcar_comments’, :size => “69x4” %>

I am describing a size but I need it to only allow a certain number of
characters and no more. Is that possible or am I going to have to right
a method that check and then kicks back an error message? Thanks,


text fields have a maxlength attribute in html, but textarea’s do not.
You could just cook up some javascript to count the characters and limit
it that way.

Shandy N. wrote:


William P.

That worked. Not pretty, but it does exactly what I want. Thanks,


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs