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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validate form

Status
Not open for further replies.

redbay

Technical User
Oct 13, 2003
145
GB
I have a text field on my form that is a list/menu and i want to validate this but i opened the validate form from the behaviours section and my list/menu field was not available. Is it possible to validate this field?
 
For some reason the inbuily validate form behaviour does not validate list/menus. I would just call a javascript to do it

[Peace][Pipe]
 
How do you want to validate it? Just check to make sure the list/menu option is chosen? Or have another action fire off when a certian option is selected?

See if something like this is what you're looking for:
Code:
<script>
function checkMe() {
	var Gm = document.form_gm
	if(Gm.myList.options[0].selected == true) {
		alert("Please make a selection");
		return false;
	}
	if(Gm.myList.options[1].selected == true) {
		alert("Are you sure you want to go to Hotmail?");
		window.location = '[URL unfurl="true"]http://www.hotmail.com';[/URL]
		return false;
	}
}
</script>

<form name="form_gm" onSubmit="return checkMe();">
	<select name="myList">
		<option value="">Make a choice</option>
		<option value="1">Hotmail</option>
		<option value="2">Tek-Tips</option>
	</select>
	
	<input type="submit" name="Submit" value="Submit">
</form>


____________________________________
Just Imagine.
 
Both,

i came across Javascript Integration Kit on the Macromedia web site, and down loaded this to my extension manager, this has a behaviour for "Selection madde in list" which was exactly what i wanted it also allowed me to customise my own error message.

Thanks for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top