When filling the form, if input
filled incorrectly and gives the error :invalid
, then you need to add the class .error in the label
to which this input
belongs and cancel if the input
becomes :valid
.
.error { color: #f00; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <form> <label class="" for="email">e-mail</label> <input name="email" type="email"> <input type="submit" value="ok"> </form>