问题描述
我使用一个textarea字段在一个形式在html和处理是由php。我想限制用户可以在textarea中输入的字符数。有什么办法可以做到这一点,因为textarea字段然后存储到一个mysql数据库,因此我必须根据字段的varchar值限制用户数据。
I am using a a textarea field in a form that is made on html and the processing is done by php. I want to limit the number of characters the user can enter in the textarea. Is there any way by which this can be done because the textarea field is then stored into a mysql database and thus i have to limit the user data according to the varchar value of the field.
任何帮助?
推荐答案
您可以通过设置 maxlength $ c $在HTML中的textarea标签上的
函数。< textarea maxlength =120>< / textarea>
$ c> substr()
You can limit this by setting maxlength
attribute on textarea tag like <textarea maxlength="120"></textarea>
in HTML and additionally "cut" input string in PHP by substr()
function.
这篇关于如何限制textarea字段中处理php的字符数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!