How can I color input fields border red when I get validation error laravel 5.3 -
my validation controller:
public function store(request $request) { // dd($request->all()); /////validations//// $this->validate($request, [ 'name' => 'required|min:3|', 'email' => 'required|unique:customers' , 'favorite' => 'required', 'password' => 'required|min:6', 'confirm_password' => 'required|same:password', ]); $user = new customer; $user ->name=input::get("name"); $user ->email=input::get("email"); $user ->country=input::get("country"); $user ->gender=input::get("gender"); $user ->favorite=implode(" , " , input::get("favorite")); if(input::hasfile("image")){ $files = input::file('image'); $name = time()."_". $files->getclientoriginalname(); $image = $files->move(public_path().'/image' , $name); $user->image=$name; } $user ->psw=input::get("psw"); $user->save(); return redirect("showall"); }
insert.blade.php
<form action="store" method="post" enctype="multipart/form-data"> <ul><span style="color:red;">{!! $errors->first('name') !!}</span></ul> <label for="name">name</label> <input type="text" name="name" value="{{old('name')}}" id="name" autofill="off"> <input type="hidden" name="_token" value="{{csrf_token()}}"> <ul><span style="color:red;">{!! $errors->first('email') !!}</span></ul> <label for="email">email</label> <input type="email" name="email" value="{{old('email')}}" id="email" autofill="off"> <br> <br> country <select name="country" id="country"> <option value="usa">usa </option> <option value="england">england </option> <option value="japan">japan </option> <option value="italy">italy</option> </select> <br> <br> gender <input type="radio" name="gender" value="male">male <input type="radio" name="gender" value="female">female <br> <br> <ul><span style="color:red;">{!! $errors->first('favorite') !!}</span></ul> <input type="checkbox" name="favorite[]" value="sout">south <input type="checkbox" name="favorite[]" value="north">north <input type="checkbox" name="favorite[]" value="east">east <input type="checkbox" name="favorite[]" value="west">west <br> <br> <input type="file" name="image"> <br> <br> <ul><span style="color:red;">{!! $errors->first('confirm_password') !!}</span></ul> <label for="email">password</label> <input type="password" name="password" value="" id="password"> <ul><span style="color:red;">{!! $errors->first('confirm_password') !!}</span></ul> <label for="email">confirm password</label> <input type="password" name="confirm_password" value="" id="cpsw"> <br> <br> <label for="submit"></label> <input type="submit" name="submit" value="submit" id="submit"> </form>
form want change fields color:
i want change input fields border color change red when validation error. try best don't know how rid off problem.
add css code first:
.form-error { border: 2px solid #e74c3c; }
and html code ::
<input type="text" class="form-control{{($errors->first('name') ? " form-error" : "")}}" name="name" placeholder="name">
Comments
Post a Comment