Friday, April 5, 2013

Javascript : Checkbox Validation



<html>

<head>
<script LANGUAGE="JavaScript">function ValidateForm(form){
ErrorText= "";if ( ( form.gender[0].checked == false ) && ( form.gender[1].checked == false ) ) 
{
 alert ( "Please choose your Gender: Male or Female" ); 
 return false;
  }
if (ErrorText= "") { form.submit() }
}
</script>
</head>
<body>

<form name="feedback" action="#" method=post>

Your Gender: <input type="radio" name="gender" value="Male"> Male

<input type="checkbox" name="gender" value="Female"> Female

<input type="checkbox" name="SubmitButton" value="Submit" onClick="ValidateForm(this.form)">

<input type="reset" value="Reset">

</form> 

</body>

</html>
Your Gender: Male Female

Related Posts Plugin for WordPress, Blogger...