Laravel 表单输入 - 如何设置 maxlength

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27525832/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 10:34:07  来源:igfitidea点击:

Laravel form inputs - how to set maxlength

phpformslaravelinputmaxlength

提问by Tomas Turan

Maximal length of HTML inputs can be set by: <input type="text" name="" maxlength="10">Is there a way how to set maxlength of form input when creating inputs in Laravel way?

可以通过以下<input type="text" name="" maxlength="10">方式设置 HTML 输入的最大长度:在以 Laravel 方式创建输入时,有没有办法设置表单输入的最大长度 ?

{{ Form::text('name', null, array('placeholder' => '')) }}

回答by Joe

{{ Form::text('name', null, array('placeholder' => '','maxlength' => 10 )) }}

Works with the Chrome Version 39.0.2171.95 (64-bit)

适用于Chrome 版本 39.0.2171.95(64 位)

回答by Naing Lin Aung

You can also check in validation as follow. For more details, you can take a look in validation

您还可以按如下方式检查验证。有关更多详细信息,您可以查看验证

$validator = Validator::make(
    array('name' => 'name'),
    array('name' => 'required|max:5')
);