Guest User

Untitled

a guest
Aug 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. <%= submit_tag 'Submit', :onclick => 'return validate(this)' %><br/>
  2.  
  3. <script type="text/javascript" charset="utf-8">
  4. function validate() {
  5. var valid = false;
  6. var radio_groups = {}
  7. $(":radio").each(function(){
  8. radio_groups[this.name] = true;
  9. })
  10. for(group in radio_groups){
  11. if (!!$(":radio[name="+group+"]:checked").length) {
  12. valid = true;
  13. }
  14. }
  15. if (!valid) {
  16. alert('you forgot to check a radio button somewhere');
  17. return false;
  18. }
  19. }
  20. </script>
Add Comment
Please, Sign In to add comment