Download & Extend

How do i Validate vote on the client side

Project:Fivestar
Version:6.x-1.18
Component:Documentation
Category:support request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Hi
I need to implement validation check if the user has voted on the client side (show a msg & stop the form submission)
i know how to add onSumbit function to the form for validation (here is a sample- http://drupal.org/node/179994)

my question is how can i know the user has not voted yet ?

i see that there is a Select tag that is hidden and using the stars to votes does not change it
the only change i saw is that the star-N class was added a "on" class
i want my code to be genreic - so browsers that doesn't supports the widget , will work too

is that the way to check , or am i missing something here ?

Thanks Avior

Comments

#1

I will be happy is someone can give me a lead to start with

#2

this is what i did

on form_alter hook i have added

$form['#attributes']['onsubmit'] = 'return comment_cs_validate()';

i have added this function to the tpl file (in my case it was a view)

<script type="text/javascript">
      function comment_cs_validate() {
        if ($('#edit-vote-0-wrapper div div').hasClass("on")) {
          return true;
        } else {
          alert ('You must rank the story before submitting your post');
          return false;
        }
      }
      </script> 

i guess that there is a better way (a more genreric one)

#3

I was also searching for some more generic way but didn't find yet, still for those who are suffering from this and searching for some nice fix can try this http://drupal.stackexchange.com/questions/16690/client-side-form-validat...

Drupal 7.x