Laravel Two values โ€‹โ€‹should not be equal.

In Laravel 4, I am trying to find confirmation confirmation for input values. For example, with confirmation we can verify the matching password and re-password, and now I want to check the opposite of the two values. for example, A must be not equal to A in the input values, and after checking the rules I should be a return error. In this example, how to check this?

 <input id="starttime_range" name="starttime_range" type="text" class="form-control" /> <input id="finish_range" name="finish_range" type="text" class="form-control" /> 

starttime_range must not be equal to finish_range

My code is:

 public function postInsert() { $rules = array( 'starttime_range' => 'required|integer', 'endtime_range' => 'required|integer|not:starttime_range', ); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::back() ->withErrors($validator) ->withInput(); } else { } } 
+5
source share
1 answer

If you want two different values โ€‹โ€‹in the cluster, you need to use different:

  $rules = array( 'starttime_range' => 'required|integer', 'finish_range' => 'required|integer|different:starttime_range', ); 
+10
source

All Articles