styleBunny
Technical User
Hi All,
I have this function to validate, whether a users has made a selection from a multiple selection list box.
I can get the length value returned when the array is static, but when its a dynamic array, created inside a form I haven had any luck!
Thanks for looking,
sb.
I have this function to validate, whether a users has made a selection from a multiple selection list box.
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script language="javascript">
function validateContactForm(form) {
if (form.foo.length == 0) {
alert('Please select.');
return false;
}
}
</script>
</head>
<body>
<form name="contact" method="post" onSubmit="return validateContactForm(this);">
<select name="foo[]" size="5" multiple>
<option value="apples">Apples</option>
<option value="oranges">Oranges</option>
<option value="pears">Pears</option>
<option value="grapes">Grapes</option>
<option value="mangos">Mangos</option>
</select>
<br>
<input type="submit" name="btnSubmit" value="Submit"> <input type="reset" name="btnReset" value="Clear">
</form>
</body>
</html>
I can get the length value returned when the array is static, but when its a dynamic array, created inside a form I haven had any luck!
Thanks for looking,
sb.