Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jsf radio button and javascript  RSS feed

 
Mike Mentzer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to apply javascript validation on radio button so that atleast one radio must be selected.

This is my radio tag.




This is my command button. onclick of which i am calling a javascript function validatemanual2().




Below is my javascript function. Problem is , that i am getting the value of chkBoxName (in red) as undefined.
so i am not able to go inside the if (check == true) block.



Any help or suggestion would be greatly appreciated..
 
Rajneesh K Rajput
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you are sure, you need to do this? If you are using radio buttons, and they are all part of same id, one of them will always be selected.
There is no way that you can deselect all, once one of them is already selected.

And, by default to keep one as selected once page is rendered you can use value attribute, to display default selected component.

In order to do above, simply check if your checkVal is null then simply fill this with default value, before returning in getter of the same. This will take care of everything.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!