Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom validator not being checked on Update :s

Status
Not open for further replies.

N3XuS

Programmer
Mar 1, 2002
339
BE
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:
Code:
			<script language="javascript">

			function validateLength ( src, arg ) {
				alert(document.getElementById("lstLoc2").length);
				if (document.getElementById("lstLoc2").length > 0){
					arg.IsValid = true;
				}
			}
			</script>
The validator:
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 ?
 
Why aren't you just using a RequiredFieldValidator?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Lol good question ... I looked over the listbox names .. though I couldn't use'm on listboxes ... Anyhow I found some areticle about how custom controls don't work for listboxes and ea checking if a checkbox is checked in a list. Go figure.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top