<html>
<head>
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<script type="text/javascript" src="js/validate2.js"></script>
<title>Registration Form</title>
<style type="text/css">
<!--
label
{
display: block;
color: #FF0000;
font-style: bold;
}
-->
</style>
</head>
<body>
<form method="POST" id="registerForm" action="next_stage.php">
<select size="1" name="colour">
<option selected value="">Select....</option>
<option value="blue">Blue</option>
<option value="red">Red</option>
<option value="other">Other</option>
</select>
<input type="text" name="colour2" id="colour2"/>
<input type="submit" value="Submit" name="B1">
</form>
</body>
</html>
validate2.js:
$(document).ready(function(){
$("#registerForm").validate({
rules: {
colour: "required",
colour2: {
required: function(element) {
var flag = false;
if($("#colour").val()=="other")
{
if($("#colour2").val()=="")
flag = true;
}
return flag;
}
}
}
});
});
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.