I'm trying to write my own function to evaluate input fields to see if they have a value. So I've written this for loop:
$("button").click(function(){
for (var ii = 0; ii < personalInfo.length; ii++) {
if ($(personalInfo[ii]).val() == 0) {
$(personalInfoLabels[ii]).addClass("required");
}
else{
$("button").parent("fieldset").slideUp();
}
};
});
As of now the loop has no problem identifying the positions of the array that are empty and labeling them correctly.
However, if any of the positions have a value the event happens. How can I say if each position of the loop has a value, fire event, but if not label the required field?
A JSFiddle of the code is available at http://jsfiddle.net/bjKX7/