ROR +如何制作具有少量验证和属性条件的 Textarea
在这里,在我的代码中,我必须放置一个 text_area,并且我必须在它们上面放置一些特定的条件。我使用过的代码。 Ruby 代码::
<%= text_area "rate_unit","rate_unit_notes", "rows" => 3, "cols" => 50,
:tabindex=>3, :maxlength=>100 %>
执行页面后的 HTML 代码
<textarea tabindex="3" rows="3" name="rate_unit[rate_unit_notes]" maxlength="100"
id="rate_unit_rate_unit_notes" cols="50"></textarea>
但问题是 maxlength 选项不起作用。我想应用于此文本区域的条件名称::最大长度、大小、类别、自动完成。建议我..
Here, In my code I have to put one of the text_area and i have to put some certain condition over them. Code which was used by me.
Ruby Code::
<%= text_area "rate_unit","rate_unit_notes", "rows" => 3, "cols" => 50,
:tabindex=>3, :maxlength=>100 %>
HTML Code after executing the page
<textarea tabindex="3" rows="3" name="rate_unit[rate_unit_notes]" maxlength="100"
id="rate_unit_rate_unit_notes" cols="50"></textarea>
But issue is that maxlength option is not working. Name of condition which i want to applied on this textarea :: maxlength, size, class, autocomplete. Suggest me ..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HTML 中没有任何技术可以对 text_area 执行此操作。字符数限制仅存在于输入[文本]上。
因此,您可以通过示例使用 Javascript 来阻止此限制。但在每种情况下,都无法避免用户输入超过 100 个字符。所以你需要在你的服务器端验证,不超过100个字符。
There are no technique in HTML to do that with text_area. The limit number of character exist only on input[text].
So you can block this limit with Javascript by example. But in each case, nothing avoid user to put more than 100 character. So you need validate in your server side, that are not more than 100 characters.