设置Laravel Form :: number的Maxlength(

时间:2017-12-25 00:08:57

标签: php laravel validation

我有这段代码

{{ Form::number('amount', (isset($logged_in_user->paymentConfirmation->amount) ? floor($logged_in_user->paymentConfirmation->amount) : null), ['class' => 'form-control', 'maxlength' => '13','step' => '1']) }}

如何将长度限制为13位数?

1 个答案:

答案 0 :(得分:0)

Laravel Collective Forms将Form::number呈现为<input type="number">元素。所以你需要在这里使用max,它的值必须是允许的最大整数:

{!! Form::number('amount', (isset($logged_in_user->paymentConfirmation->amount) ? floor($logged_in_user->paymentConfirmation->amount) : null), ['class' => 'form-control', 'max' => '9999999999999', 'step' => '1']) !!}

https://www.w3schools.com/tags/att_input_max.asp