Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Unchecked radio not passing null  RSS feed

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i need to know how can i validate that a radio button has been checked.


the below null checking is not working.

servlet 1:
out.println("<input type=radio name=chbx id=xcv value="+getid+">");

servlet 2:
String book = request.getParameter("chbx");
if(book == null){
response.sendRedirect("/servlet");
}
 
author & internet detective
Marshal
Posts: 38502
653
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You only have one radio button? Radio buttons are typically a group of things. It seems lie you'd want a checkbox here.

Also, try outputting this to see what the value is. That will give a clue why it isn't what is expected.


 
Mo Alexwainy
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No this is a set of radio buttons automatically generated in a table whenever a record is added/parsed.
Even if i dont click a radio button and click the edit button to call a servlet to edit this record, i am not able to catch a null string.

So in the first servlet, let's suppose no radio button is selected and user clicked edit a blank page i need the user to stay on this page not going to a blank page.

 
Author and ninkuma
Marshal
Posts: 66783
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With a radio button group, the value of the single parameter will be the value attribute of whichever radio button is checked. You will not get null values for unchecked buttons.

Your page should make sure that at least one default choice is checked when the page is presented to the user.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!