Note that there are some explanatory texts on larger screens.

plurals
  1. POValidation for a required element, jQuery Star Rating
    primarykey
    data
    text
    <p>I use <a href="http://www.fyneworks.com/jquery/star-rating/" rel="nofollow">fyneworks.com/jquery/star-rating/</a> to make a star rating on my site. But I have some trouble with validation with jquery. I want that the user must use it.</p> <p>I use this:</p> <pre><code> $('#formid').validate({ rules: { nameofradiobutton: { required: true } } }); </code></pre> <p>to validate but with the normal <code>{ required: true }</code> it doesn't work.</p> <p>But I want to have it in an format like rules.</p> <p>Please help me search for a solution lots of hours but I can't find an solution that work...</p> <p>My radio HTML looks like this:</p> <pre><code>&lt;input name="star" type="radio" value="1"class="star"/&gt; &lt;input name="star" type="radio" value="2"class="star"/&gt; &lt;input name="star" type="radio" value="3"class="star"/&gt; &lt;input name="star" type="radio" value="4"class="star"/&gt; &lt;input name="star" type="radio" value="5"class="star"/&gt; </code></pre> <p>And my actual validate call looks like this:</p> <pre><code>$('#starform').validate({ rules: { star: { required: true, }, }, messages: { star: { required: "&lt;br /&gt;Please choose a star.", }, }, errorPlacement: function (error, element) { if ( element.is(":checkbox") ) error.appendTo(element.parent("td").next("td")); else if ( element.is(":radio") ) error.appendTo(element.parent("td").next("td")); else error.appendTo( element.parent()); } }); </code></pre> <hr> <p>My Form is like this</p> <pre><code>&lt;input name="star" type="radio" value="1"class="star"/&gt; &lt;input name="star" type="radio" value="2"class="star"/&gt; &lt;input name="star" type="radio" value="3"class="star"/&gt; &lt;input name="star" type="radio" value="4"class="star"/&gt; &lt;input name="star" type="radio" value="5"class="star"/&gt; </code></pre> <p>and my validation is like these</p> <pre><code> $(document).ready(function () { $('#starform').validate({ rules: { star: { required: true, }, }, messages: { star: { required: "&lt;br /&gt;Please choose a star.", }, }, errorPlacement: function (error, element) { if ( element.is(":checkbox") ) error.appendTo(element.parent("td").next("td")); else if ( element.is(":radio") ) error.appendTo(element.parent("td").next("td")); else error.appendTo( element.parent()); } }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload