I have a script which validates each stage of a form and adds a tick or cross to each section if the validation is without errors or not.
Here is my code:
var error = 1;
var hasError = false;
$('.edit_artist').children(':nth-child(' + parseInt(step) + ')').find('input:not(button)').each(function() {
var $this = $(this);
var valueLength = jQuery.trim($this.val()).length;
if(valueLength == '') {
hasError = true;
}
I dont want the validation to occur on all input fields, so I want to be able to validate inputs by class. Is there a way of finding inputs by class or would I need to go down another route to achieve this?
Thanks
To find an element based on its
class, and while excludingbuttonelements:Or, a more verbose manner:
References:
filter().find().