Thanks for your reply.
This is what I did, I already saw this before posting .attr()
So with the idea you gave me, I add required where the condition shows.
$("#checkId").attr('required', '');
Works great, and since you can also delete rows, I added this to not require if you decide to delete the row.
$(document).on('click', 'button.removebutton', function () {
$(this).closest('tr').remove();
$("#checkId").removeAttr('required');
checkExtras();
return false;
});
The next code lets me show the divs with terms, and not hidde it. If at least one input makes the condition true, else it used to hide again if you edited it even when there was other input with the condition true.
But I don’t understand this code below, someone else did it and the explanation was to poorly for my level of understanding. I’ve tried to understand or search .each but its not quite expressed has in this example.
I don’t like using something I don’t understand, even it works great.
Could you explain this code:
$('.skillTable').on('change', ".skillSelect", function() {
checkExtras()
})
function checkExtras() {
let hasExtras = false;
$(".skillSelect").each(function(i, o) {
let optgroup = $(o).find(':checked').closest('optgroup').attr('label');
if (optgroup === 'External Roles') hasExtras = true;
})
$(".terms").toggle(hasExtras);
}
You helped me with the next part, that I added and worked great and I know how it works.
// Set a blank value when edit email
$(document).on('keyup change', `.email${i}`, function() {
$(this).closest('tr').find(`.blank${i}`).prop('selected', true);
checkExtras();
});
}
When the user edits his email, blank gets selected, since the select is the one that determinates to show terms or not. and if theres no other condition the terms div gets hidden, and u can reselect again your options and then it shows again or not.
How do I do something similar for the checkbox. I want if you edit and its sets to a blank. to remove “required” only if theres no other input or select that has the condition.
So thats why I guess I need to understand that part that I don’t.
Don’t know if its better to add more code or a fiddle, I just tought it was a simple html css stuff, didn’t wanted to post so much text.
Thanks