我在自定義注冊表單中使用警報來獲取唯一的電子郵件和電話,但它不起作用不工作的代碼@if ($errors->has('email'))<span class="invalid-feedback" role="alert"><strong>{{ $errors->first('email') }}</strong></span>@endif@if ($errors->has('phone'))<span class="invalid-feedback" role="alert"><strong>{{ $errors->first('phone') }}</strong></span>@endif當我在下面的代碼中使用它時它工作但它顯示輸入區域下方的所有錯誤,代碼 @if($errors->has('email')) @foreach($errors->all() as $error) <li style="color:red">{{ $error }}</li> @endforeach @endif @if($errors->has('phone')) @foreach($errors->all() as $error) <li style="color:red">{{ $error }}</li> @endforeach @endif
1 回答

動漫人物
TA貢獻1815條經驗 獲得超10個贊
嘗試以下示例以顯示單個錯誤
@if ($errors->any())
<label for="email" class="error">{{ $errors->first('email') }}</label>
@endif
@if ($errors->any())
<label for="phone" class="error">{{ $errors->first('phone') }}</label>
@endif
- 1 回答
- 0 關注
- 87 瀏覽
添加回答
舉報
0/150
提交
取消