hello i have this form and i have validations for it. I have already finished doing the validations for in inside my controller and i can already display the error messages in my view but i wanted the error message to be beside the input area where it came from here is my code in the view
{{ Form::open(array('url' => 'addParentAccnt')) }} <div class="form-group"> {{ Form::label('username', 'Username') }} {{ Form::text('username', Input::old('username'), array('class' => 'form-control','placeholder' => 'Insert username')) }} </div> <div class="form-group"> {{ Form::label('fName', 'First Name') }} {{ Form::text('fName', Input::old('fName'), array('class' => 'form-control','placeholder' => 'Insert First Name')) }} </div> <div class="form-group"> {{ Form::label('lName', 'Last Name') }} {{ Form::text('lName', Input::old('lName'), array('class' => 'form-control','placeholder' => 'Insert Last Name')) }} </div> {{ Form::submit('Proceed to Next Step', array('class' => 'btn btn-primary')) }} {{ Form::close()}} in the bottom of my view i added this code to display the error messages
@if ($errors->any()) <ul> {{ implode('', $errors->all('<p style="color:red" class="error">:message</p>')) }} </ul> @endif the code inside my controller is this
$rules = array ( 'username' => 'required|min:10|max:50', 'fName' => 'required|alpha|min:1|max:80', 'lName' => 'required|alpha|min:1|max:80', ); $validator = Validator::make(Input::all(), $rules, $messages); if ($validator->fails()) { return Redirect::to('createPa') ->withErrors($validator) ->withInput(Input::except('password')); } else { //do something }