I like using jquery validate to validate my forms, I have to use a background image for the radio input.
below is the html, css and jquery for the validation.
I decided to add a simple radio: and added it to the rules and it displayed the error message when I tried to submit the form, only for that input, but not for upgrade or route radio fields.
This makes me believe the img background hack for a radio field is causing the validation not to work. Probably because I have display: none; for the radio input type in the css.
HTML:
<input type="radio" id="u1" name="upgrade" value="1" />
<label for="u1"><span></span></label>
CSS:
input[type="radio"] {
display:none;
}
input[type="radio"] + label {
color:#f2f2f2;
font-family:Arial, sans-serif;
font-size: 14px;
position: absolute;
top: 25px;
right: -3px;
}
input[type="radio"] + label span {
display:inline-block;
width: 38px;
height: 28px;
margin:-1px 4px 0 0;
vertical-align:middle;
background:url('../images/sub-vote-box-checkbox.png') no-repeat;
cursor:pointer;
}
input[type="radio"]:checked + label span {
background:url('../images/sub-vote-box-checkbox-checked.png') no-repeat;
}
JavaScript:
$("#vote-route-upgrade-form").validate({
rules: {
route: {
required: true,
},
upgrade: {
required: true,
},
},
submitHandler: function() {
$('#vote-modal').modal('hide');
$('#thanks-modal').modal('show');
}
});