Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set maximum length in Text field in RoR

Has anyone managed to set maximum field lenghts for text fields

How can i set the maximum length of a text field. Here is the code iam using

<%= text_field_tag(:create_text), :input_html => {:maxlength => 15, :size => 40}  %> 

but I cannot seem to set the max number of characters that can be typed into the field.

like image 477
divz Avatar asked Apr 23 '13 10:04

divz


People also ask

What is length max length text can be?

The maximum number of characters for a text message is 160 characters, including spaces.


1 Answers

Here is how you can do it:

<%= text_field_tag 'create_text', nil, :maxlength => 15, :size => 40 %> 

Source: http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-text_field_tag

like image 195
M. Cypher Avatar answered Sep 24 '22 09:09

M. Cypher