I am having trouble in the IE11 browser to get my validation to work properly.
Basically what is going on is I have select lists, which when chosen show the selected values in another textarea to allow the users to be aware of which employee(s) or branch(es) is chosen. There are two buttons labeled "ADD ALL" and "Remove ALL".
The problem is if the form is submitted and the required fields are not chosen it shows they need to be chosen but when when you hit ADD ALL and it selects all the users it should no longer need validation. Since the ADD ALL button is being pressed it does not consider that as a selection made and still forces the user to click in the select and then re click the "ADD ALL" button.
Is there something in JS I can write that once the button is chosen the validation is no longer required again unless a user is not chosen upon submit or something?
In chrome it does it correctly but for some reason IE11 is complaining.
Any help would be greatly appreciated!
https://jsfiddle.net/aelliott/pu8kLmeb/
Steps:
- In dropdown choose checklist stats
- Select continue - don't fill out the form (validation for required fields appear.)
- Select ADD ALL on either button
- Validation does not disappear and form still cannot be submitted because selects think nothing has been chosen
CODE
function handleLocationChange() {
var selected = [];
loc.find("option:selected").each(function() {
selected.push($(this).text());
});
selectedElement.val(selected.join("\n"));
}
function setLocationOptionsSelected(selected) {
loc.find("option").prop("selected", selected);
loc.change();
}
function setSelectedOnEmployeeOptions(selected) {
EmployeeName.find("option").prop("selected", selected);
EmployeeName.change();
}
function handleEmployeeNameChange() {
var selected = [];
EmployeeName.find("option:selected").each(function() {
selected.push($(this).text());
});
selected1Element.val(selected.join("\n"));
}