dongqiu9018 2016-10-16 09:43
浏览 20
已采纳

Laravel - 验证者之间:8,11没有按预期工作

I am trying to validate phone numbers

$rules = array(
            'phone' => 'numeric|between:8,11',
            'mobile' => 'Required|numeric|between:11,15',
        );

and here is the fields

    <div class="form-group">
    {{ Form::label('phone', 'Phone', array('class'=>'col-sm-2 col-md-3 col-lg-2 row control-label label-input-sm')) }}
         <div class="col-sm-10 col-md-9  col-lg-10 ">
{{ Form::text('phone', '', array('class'=>'form-control1', 'placeholder'=>'Phone')) }}
     </div>
        </div>
  <div class="form-group">
{{ Form::label('mobile', 'Mobile', array('class'=>'col-sm-2 col-md-3 col-lg-2 row control-label label-input-sm')) }}
    <div class="col-sm-10 col-md-9  col-lg-10 ">{{ Form::text('mobile', '', array('class'=>'form-control1', 'placeholder'=>'Mobile')) }}
     </div>
</div>

when I write a number with 8 numbers

got

The phone must be between 8 and 11

whats wrong with my validator?

  • 写回答

1条回答 默认 最新

  • duanboshi1472 2016-10-16 11:28
    关注

    As per the docs, between on a numeric field validates the value of the field to be between two values.

    What you want instead is the digits_between rule

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 蓝桥oj3931,请问我错在哪里
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染