如何在创建表单时添加必填字段?
这是我的代码:
{!! Form::input('number', 'mobile', null, ['type' => 'number', 'min' => 0, 'id' => 'mobile', 'class' => 'input-lg form-control TabOnEnter', 'placeholder' => 'Eg: 9876543210', 'tabindex' => 15]) !!}
在这里,我想根据需要给出这个手机号码字段,如何在我的代码中添加它? 我在创建表单时有3个步骤,并且我在步骤1中有移动号码,当我点击下一个按钮而不添加手机号码时,它应该显示一条警报消息。现在它显示需要移动字段的警报消息,只有在步骤3的最后一步(即)中点击提交按钮后…
你需要使用jquery
用next_button
检查它
{!! Form::input('number', 'mobile', null, ['type' => 'number', 'min' => 0, 'id' => 'mobile', 'class' => 'input-lg form-control TabOnEnter', 'placeholder' => 'Eg: 9876543210', 'tabindex' => 15]) !!} $(document).ready(function(){ $('.next_button').click(function(event){ if ($('#mobile').val() == ""){ event.preventDefault(); alert('Enter the number'); } }); });
在现有代码中添加了next_button
类
将'required' => true
添加到数组中:
{!! Form::input('number', 'mobile', null, ['required' => true, 'type' => 'number'....