How would you go about validating a field if a dropdown equals to a certain value.
Example:
HTML
<form id="foo">
<!-----Dropdown----->
<select name="budget_type">
<option value="fixed" <?php if($budget_type=="fixed" ){echo "selected";} ?> >Fixed</option>
<option value="hourly" <?php if($budget_type=="hourly" ){echo "selected";} ?> >Hourly</option>
</select>
<!-----Field----->
<input id="dollar" type="text" name="budget" style="text-indent:17px;" value="<?php echo $budget; ?>" />
</form>
jQuery:
$('#foo').validate({
rules: {
budget: {
required: true,
notEquals: "0",
digits: true,
min: 50,
}
},
messages: {
budget: {
required: "Please enter a value",
min: "Minimum $ {0}",
}
}
});
So, if budget_type is fixed then minimum budget is 50 but if budget_type is hourly then minimum budget is 10. I tried the if() function but don't really know how and where to put the code.