Suppose I have a form of two input field
<input type="text" name="form-first-name" placeholder="name" class="form-first-name form-control require" id="name">
<input type="text" name="form-age" placeholder="age" class="form-first-name form-control require" id="age">
Now I want to validate these two input fields sing jquery. For that I am using
$('.registration-form input[class="require"]).on('focus', function() {
$(this).addClass('input-error');
});
But here is not validation working. But if I have use
$('.registration-form input[id="name"]).on('focus', function() {
$(this).addClass('input-error');
});
Validation is working fine.
But I want to use class otherwise I need to validate the for input fields for each id. If I can use class it will be easier for me to validate.