设置Laravel Form :: number的Maxlength(

问题描述 投票:2回答:1

我有这个代码

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

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

php laravel validation
1个回答
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

© www.soinside.com 2019 - 2024. All rights reserved.