Single Element Validate
Demonstrates how to validate a single required element on focus out if nothing is entered, using the jquery-validate plugin.
HTML
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js"></script>
<input type="radio" id="need_staff_on_site" name="data[CaterRequest][need_staff_on_site]" value="yes" class="need_staff_on_site"><span>Yes</span>
<input type="radio" id="need_staff_on_site" name="data[CaterRequest][need_staff_on_site]" class="need_staff_on_site" value="no"><span>No</span>
<br />
How many staff?<input type="text" maxlength="3" id="no_of_staff" name="data[CaterRequest][number_of_staff_needed]" class="txtboxSml2">
JavaScript
$(document).ready(function(){
$("input[name='need_staff_on_site']").change(function(){
if ($("input[name='need_staff_on_site']:checked").val() == 'yes')
{
alert('hi');
}
else{
alert('hiii');
}
});
});