How can i add required field while creating a form?

前端 未结 2 1412
囚心锁ツ
囚心锁ツ 2020-12-12 06:50

This is my code :

  
相关标签:
2条回答
  • 2020-12-12 07:04

    Add 'required' => true to the array:

    {!! Form::input('number', 'mobile',  null, ['required' => true, 'type' => 'number'....
    
    0 讨论(0)
  • 2020-12-12 07:11

    You need to check it with your next_button using jquery

      <div class="form-group">
        <div class="col-md-4">
          <label class="control-label">Mobile Number:</label>
        </div>
        <div class="col-md-8">
          {!! Form::input('number', 'mobile',  null, ['type' => 'number', 'min' => 0, 'id' => 'mobile', 'class' => 'input-lg form-control TabOnEnter', 'placeholder' => 'Eg: 9876543210', 'tabindex' => 15]) !!}
    
        <button style="margin-right:20px;" class="next_button btn btn-info active nextBtn btn-md pull-right" type="next" >Next</button>
        </div>
      </div>
    
    $(document).ready(function(){
       $('.next_button').click(function(event){
            if ($('#mobile').val() == ""){
                event.preventDefault();
                alert('Enter the number');
            }
        });
    });
    

    Added next_button class in your existing code

    0 讨论(0)
提交回复
热议问题