I have one last jQuery question for the day. I have two fields. One is a dropdown and the other is a datetime field. If the user selects No then then it needs to disable the input field and removes any value inside the datetime field or if the user selects Yes then it adds class a validation rule to the datetime field.
<div class="section _100">
<label for="comments">Allow Comments</label>
<div>
<select name="comments" id="comments">
<option value="" selected="selected">Please Select An Option</option>
<option value="0">No</option>
<option value="1">Yes</option>
</select>
</div>
</div>
<div class="section _100">
<label for="datetime">Date Comments Expire</label>
<div>
<input id="datetime" type="datetime" name="datetime" />
</div>
</div>
$('#comments').change(function(){
$('#datetime').removeAttr('disabled');
$('#comments').not(this).val(0);
$('#comments').each(function(){
if($(this).val().length > 0){
$('#datetime').attr('value','');
}
});
});
Not sure about the validation attribute…
Here is my solution to your problem…
http://jsfiddle.net/59BVn/