Text Area helper , how i set the maximum length of string to 100.
Is there is any max length attribute in text-area helper in ROR.
文本区域助手,如何设置字符串的最大长度为100。在ROR的文本区域助手中是否存在最大长度属性。
Code will help me.Thanks
代码将帮助谢谢
2 个解决方案
#1
6
By default at the View level rails doesn't provide the character limit for text area . You can explictly use Javascript function which limits the Number of the Characters entered with onKeyUp
and onKeyDown
events in your view and place the function in public/javascript/application.js
.
默认情况下,视图级别的rails不提供文本区域的字符限制。可以明确地使用Javascript函数,该函数限制在视图中使用onKeyUp和onKeyDown事件输入字符的数量,并将函数放置在public/ Javascript /application中。js。
Here is a nice tutorial for character limit within text area .
这里有一个关于文本区域内字符限制的很好的教程。
Hope it is useful !
希望它有用!
#2
2
in textarea there aren't lengths, you can set columns and rows, so you can have a textarea widht of '100 columns' but it doesn't mean that it will accept only 100 chars.
在textarea中没有长度,你可以设置列和行,所以你可以设置一个textarea widht为“100列”,但这并不意味着它只接受100个字符。
#1
6
By default at the View level rails doesn't provide the character limit for text area . You can explictly use Javascript function which limits the Number of the Characters entered with onKeyUp
and onKeyDown
events in your view and place the function in public/javascript/application.js
.
默认情况下,视图级别的rails不提供文本区域的字符限制。可以明确地使用Javascript函数,该函数限制在视图中使用onKeyUp和onKeyDown事件输入字符的数量,并将函数放置在public/ Javascript /application中。js。
Here is a nice tutorial for character limit within text area .
这里有一个关于文本区域内字符限制的很好的教程。
Hope it is useful !
希望它有用!
#2
2
in textarea there aren't lengths, you can set columns and rows, so you can have a textarea widht of '100 columns' but it doesn't mean that it will accept only 100 chars.
在textarea中没有长度,你可以设置列和行,所以你可以设置一个textarea widht为“100列”,但这并不意味着它只接受100个字符。