plodos Posted June 25, 2008 Share Posted June 25, 2008 <script LANGUAGE="JavaScript"> <!-- function ValidateForm(form){ ErrorText= ""; if ( form.age.selectedIndex == 0 ) { alert ( "Please select your Age." ); return false; } if (ErrorText= "") { form.submit() } } --> </script> <form name="feedback" action="mailto:aaa@aaa.com" method=post onSubmit="ValidateForm(this.form)"> Your Age: <select name="age"> <option value="">Please Select an Option:</option> <option value="0-18 years">0-18 years</option> <option value="18-30 years">18-30 years</option> <option value="60+ years">60+ years</option> </select> <input type="button" name="SubmitButton" value="Submit"> <input type="reset" value="Reset"> </form> I want to validate the combobox is selected or not...but onSubmit is not working :S I have already onclick evet I dont know how to combine two onclick event in one function:S What can be the errors..I couldnt find it :s Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 26, 2008 Share Posted June 26, 2008 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <script type="text/JavaScript"> <!-- function ValidateForm(form){ var ErrorText; if ( form.elements['age'].selectedIndex == 0 ) { ErrorText = "Please select your Age."; } if (ErrorText) { alert(ErrorText); return false; } return true; } --> </script> </script> </head> <body> <form name="feedback" action="" method="post" onSubmit="return ValidateForm(this);"> Your Age: <select name="age"> <option value="">Please Select an Option:</option> <option value="0-18 years">0-18 years</option> <option value="18-30 years">18-30 years</option> <option value="60+ years">60+ years</option> </select> <input type="submit" name="SubmitButton" value="Submit"> <input type="reset" value="Reset"> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.