aspose 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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
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: 46
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: 15376
    
    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: 61761
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

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://aspose.com/file-tools
 
subject: Javascript Validation for Struts Radio Button