I made a custom validator to check if there's items in a listbox. I have a whole bunch of other validators on the form so I don't wanna mix client and server side validation, and since the standard validators all are client side I want my custom one to be client side as well.
The only problem is ... the validator only validates when you actually click on an item in the listbox (in which case there is an item in the listbox obviously.) But when I submit the validator doesn't trigger ... the rest does though.
The javascript:
The validator:
Why isn't the validator triggered like all the rest when I submit ?
The only problem is ... the validator only validates when you actually click on an item in the listbox (in which case there is an item in the listbox obviously.) But when I submit the validator doesn't trigger ... the rest does though.
The javascript:
Code:
<script language="javascript">
function validateLength ( src, arg ) {
alert(document.getElementById("lstLoc2").length);
if (document.getElementById("lstLoc2").length > 0){
arg.IsValid = true;
}
}
</script>
Code:
<asp:CustomValidator id="cvLocaties" runat="server" ErrorMessage="Geen locatie aangegeven" ControlToValidate="lstLoc2"
ClientValidationFunction="validateLength"></asp:CustomValidator>
Why isn't the validator triggered like all the rest when I submit ?