I have a list of people that are being added via a search. Everything works, but there's one case where if you don't select a person from this list, you get an ugly 400 page. Obviously it's because I'm not handling the validation there.
My "remove from list" button is done this way:
<input type="button" value="Remove" onclick="delTeamNominee(document.f.teamList.value)"/>
Here's my function:
function delTeamNominee(id) {
document.dl.empId.value = id;
document.dl.submit();
}
dl
is a hidden form that executes a Spring MVC method:
<form name="dl" action="teamDeleteEmployee" method="post">
<input type="hidden" name="empId">
</form>
Obviously I would like to do something like this:
function delTeamNominee(id) {
if (id == null) {
alert("You must select a person");
} else {
document.dl.empId.value = id;
document.dl.submit();
}
}
Which of course, doesn't work.