2016-10-30 56 views
-1

我已按照此Blog進行多表驗證。我按原樣下載了該項目並運行該項目。一切正常,但驗證不起作用。現在消息顯示,而我張貼空表格。 下面是代碼:驗證在註冊和登錄表單上不起作用

<form class="form-horizontal" role="form" method="POST" action="{{ url('/register') }}"> 
    {{ csrf_field() }} 
    <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}"> 
     <label class="col-md-4 control-label">Name</label> 

     <div class="col-md-6"> 
      <input type="text" class="form-control" name="name" value="{{ old('name') }}"> 

      @if ($errors->has('name')) 
       <span class="help-block"> 
        <strong>{{ $errors->first('name') }}</strong> 
       </span> 
      @endif 
     </div> 
    </div> 

    <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}"> 
     <label class="col-md-4 control-label">E-Mail Address</label> 

     <div class="col-md-6"> 
      <input type="email" class="form-control" name="email" value="{{ old('email') }}"> 

      @if ($errors->has('email')) 
       <span class="help-block"> 
        <strong>{{ $errors->first('email') }}</strong> 
       </span> 
      @endif 
     </div> 
    </div> 

    <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}"> 
     <label class="col-md-4 control-label">Password</label> 

     <div class="col-md-6"> 
      <input type="password" class="form-control" name="password"> 

      @if ($errors->has('password')) 
       <span class="help-block"> 
        <strong>{{ $errors->first('password') }}</strong> 
       </span> 
      @endif 
     </div> 
    </div> 

    <div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}"> 
     <label class="col-md-4 control-label">Confirm Password</label> 

     <div class="col-md-6"> 
      <input type="password" class="form-control" name="password_confirmation"> 

      @if ($errors->has('password_confirmation')) 
       <span class="help-block"> 
        <strong>{{ $errors->first('password_confirmation') }}</strong> 
       </span> 
      @endif 
     </div> 
    </div> 

    <div class="form-group"> 
     <div class="col-md-6 col-md-offset-4"> 
      <button type="submit" class="btn btn-primary"> 
       <i class="fa fa-btn fa-user"></i>Register 
      </button> 
     </div> 
    </div> 
</form> 

根據碼錯誤應該顯示。我不明白爲什麼它不工作。

+0

您是否在「請求」或「控制器」中添加了驗證?如果不檢查laravel文檔,有很多示例https://laravel.com/docs/5.2/validation – Roman

+0

添加您的控制器代碼。 – Sovon

+0

是的驗證規則是否存在,其將更清晰地向您展示,您訪問我提供的博客 –

回答

-1

您的後控制器中沒有驗證規則或不正確的驗證規則。

+0

*「我認爲」*是評論,您有足夠的代表在問題下這樣做。 –