I have a form and in which I enter 1 Email which in my BD I put the field as Unique the problem that arises is when reloading a record with the same email I get the SQL error that the field is already registered, but I would like to be able to validate that field with Ajax so that I do not miss that error and I am really new with this from Ajax and Laravel 5.2
<form method="POST" action="correcto" name="formulario">
<label>Correo electrónico</label>
<input type="email" name="email" id="email" class="form-control">
<button class"btn" type="submit" value="enviar"></button>
</form>
This is my route
Route::post('correcto', 'RegistroController@recibir');
This is my driver where I enter the record to my BD
public function recibir (Request $request){
$email = $request->input('email');
$guardado = new Registros;
$guardado->email = $email;
}
I have researched a bit and I am seeing more or less the structure that should form the request with Ajax but I do not know how to structure everything