I have error div that will appear when the form is submitted to the server,
<p>
<input id="first_name" class="form-control" type="text" name="first_name" onkeyup="remove_error()" placeholder="First Name"> \
<span id="error_first_name" class="err alert alert-danger">
The first name may only contain letters.
<br>
The first name must be at least 2 characters.
</span>
</p>
I have this code:
$("#first_name").keyup(function(e)
{
$("#error_first_name").fadeOut();
});
I am planning to change it to
<input id="first_name" class="form-control" type="text" name="first_name" onkeyup="remove_error()"placeholder="First Name">
so that I can just call a function where it will remove the error in the same div with 'err' class. This is do-able if I will type in all input item 1 by 1, how can I make it to be a function where I can just call and remove the said div?
function remove_error()
{
$(this).next(".err").fadeOut(); //get next div with err class and fadeout
}