i have this function in jquery that verify if ALL the fields have at least one character inputed, i mean, if they are not empty, as you can see in the code below:
function validateStep(step){
if(step == fieldsetCount) return;
var error = 1;
var hasError = false;
$('#formElem').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;
}
});
var $link = $('#navigation_form li:nth-child(' + parseInt(step) + ') a');
$link.parent().find('.error,.checked').remove();
var valclass = 'checked';
if(hasError){
error = -1;
valclass = 'error';
}
$('<span class="'+valclass+'"></span>').insertAfter($link);
return error;
}
it happens that in such a big form i have, there is one field that is not required. I still have some difficult in implementing jquery code and i don't see what if i can insert in the middle of this function to say that specific field is not required.
Can anyone give me a little help?
Thanks in advance!