Reputation:
So i have this:
<p:selectOneRadio id="gender" style="display: inline-table">
<f:selectItem id="male" itemLabel="Male" itemValue="male"/>
<f:selectItem id="female" itemLabel="Female" itemValue="female"/>
</p:selectOneRadio>
And I want to see if the user has checked let's say the male option:
if($("#male").is(":checked") === true){
errors.push("gender");
}
But this does not work. How can I write the above script in order to checked if the male option has been clicked?
Upvotes: 0
Views: 43
Reputation: 722
You can set an option to checked by doing:
$('input[name=gender]:first').prop('checked', true);
You can check if an option is checked with:
if($('input[name=gender]:first').is(':checked')) {
console.log("option is checked");
}
Upvotes: 0