File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Javascript Validation for Struts Radio Button Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Javascript Validation for Struts Radio Button" Watch "Javascript Validation for Struts Radio Button" New topic
Author

Javascript Validation for Struts Radio Button

Mark Butcher
Ranch Hand

Joined: Jun 28, 2012
Posts: 41
Hi there,

I am working on struts 1.3 application.

I am fetching list from database and displaying them dynamically as radio buttons.
I am using html:radio tags. Now I want to validate these radio buttons and
alert that atleast one radio button is mandatory.

Thanks,
Mark.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15357
    
    6
Have you done any JavaScript validation before? What trouble are you having?

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56185
    
  13

First, ditch any illusion that the fact that the elements are generated by Struts tags has anything at all to do with it. Those tags execute on the server and end up sending plain old HTML to the browser. It's that HTML that matters. A View Source, or opening the JavaScript debugger, will reveal the HTML sent to the browser. That's what your JavaScript code will be working with.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56185
    
  13

If you're using jQuery, the check is as easy as:
Assuming that the name of the radio group is group -- change accordingly.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Javascript Validation for Struts Radio Button
 
Similar Threads
preselect a radio button
JRadio
how to display a textbox when a radio button is selected
Problem in Struts radio button
Radio