function validateFields() {
var isValid = true;
$('.membership-form').each(function(index, value){
$(this).find(':input').each(function(index, value) {
// Exclude some fields
if ($(this).attr('class') === 'picker__button--today' ||
$(this).attr('class') === 'picker__button--close'||
$(this).attr('id') === 'id_form-0-first_name' ||
$(this).attr('id') === 'id_form-0-last_name' ||
$(this).attr('id') === 'id_form-0-email' ||
$(this).attr('id') === 'id_coc_number') {
return true;
}
if ($(this).val() === '') {
$(this).addClass('error');
isValid = false;
} if (!document.getElementById('id_terms_conditions_checkbox').checked &&
!document.getElementById('id_initial_payment_checkbox').checked){
$('.custom-checkbox-check').addClass('error');
isValid = false;
}
else if ($(this).val() !== '' && $(this).hasClass('error')) {
$(this).removeClass('error');
}
});
});
return isValid;
}