i have a small question. How do i make the raty rattings become validated in the form?
Because when i uses this code
$('#rating-webratting').raty({
hints : ['1 Star', '2 Stars', '3 Stars', '4 Stars', '5 Stars'],
scoreName : 'rating-webratting',
path : 'img/',
starOn : 'star_on.png',
starOff : 'star_off.png'
});
on this div
<div id="rating-webratting"></div>
When the pages load it will create this html codes inside the div
<img title="1 Star" alt="1" src="img/star_off.png">
<img title="2 Stars" alt="2" src="img/star_off.png">
<img title="3 Stars" alt="3" src="img/star_off.png">
<img title="4 Stars" alt="4" src="img/star_off.png">
<img title="5 Stars" alt="5" src="img/star_off.png">
<input name="rating-webratting" type="hidden">
But i could not add the class="required" into the input field because its generated by the script itself.
Can anyone please advise on how to do that for the jquery validation?
i have tried the addMethod but i cant add in the class into it.
You shouldn't add the required class but the attribute thus:
$('input[name="rating-webrating"]').attr('required', true);
Since validate also ignores hidden fields by default you should also set the ignore option to an empty array like this:
$('form').validate({
ignore: []
})