I need to check through multiple paragraphs that contain input fields, i loop through each input field checking data has been entered, however i have groups of check boxes i need to check to see if at least one has been selected.
i have a loop through each input element and checking the parents are different, if not i am trying to store these in an array for validation later on, the problem i am having is the input filed with the same parent is still being added to the array and the value being stored is jQuery.fn.init[1]
.
$elementParent = $(currentElement).parent();
if(jQuery.inArray($elementParent, $checkboxArray) == -1)
{
$checkboxArray.push($elementParent);
}
Further on in the code i get an error with the .each
function, error given: Uncaught TypeError: $checkboxArray.each is not a function
$checkboxArray.each(function(index,checkboxParent){
$checkboxItems = checkboxParent.find('input[checkboxG=checkbox_group]');
$checkboxItems.each(function(index,item) {
if($(item.prop("checked")))
{
$checkboxError = false;
}
});
if ($checkboxError == true)
{
alert("error");
}
});
i have made a simple version of my error. https://jsfiddle.net/1b5ufnev/