0

I'm using Clickable star ratings for my e-commerce web site. I have followed the instructions provided within this tutorial:

http://blog.youbility.de/en/clickable-star-ratings-in-magento/

Now I'm trying to accomplished that star rating is required entry. So when I use the class name "required-entry" in the following code of line:

<input type="radio" name="ratings[<?php echo $_rating->getId() ?>]" id="<?php echo $this->escapeHtml($_rating->getRatingCode()) ?>_<?php echo $_option->getValue() ?>" value="<?php echo $_option->getId() ?>" class="radio rating-input" />

just at the end of the code where is says: class=radio rading-input i have made the change so it looks: class=radio rading-input required-entry

Now star rating becomes required-entry, but it becomes required-entry for all the five starts - and i need to make five stars required-entry as one field.

Thanks.

1

I did same thing but the different way. Instead of putting required-entry class to radio, I add new validation rule to that form.

Please put below code in your review form page, it might be work for you:

<script type="text/javascript">
    //<![CDATA[
    var dataForm = new VarienForm("review-form", true);

    Validation.addAllThese(
            [
                ['validate-rating', '<?php echo $this->__('Please select one of each of the ratings above') ?>', function (v) {
                            return false;

                }]
            ]
            );
    //]]>
</script>

Here is the output of validation: enter image description here

Let me know if you have query for the same.


For single rating option:

enter image description here

  • this works perfect. Thanks Jayesh very much. – user15151 Feb 2 '16 at 10:27
  • Great, happy coding ... :) – Jayesh Patel Feb 2 '16 at 10:29
  • Hi again. Sorry my bed. I just noticed that when I do not select star rating it asks me to select one of five start - which is OK. But. than again, when I select one star, it still keeps me asking to select the star? Any idea? – user15151 Feb 2 '16 at 10:43
  • How many rating options are enabled in your store, it will prompt you for all required rating option in my case it is Quantity, Price & Value. I need to select star for each rating. – Jayesh Patel Feb 2 '16 at 10:50
  • Where is only one option in my case, which is the Value. Thanks. – user15151 Feb 2 '16 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.