Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Radio Validator

 
Zhixiong Pan
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,

Below code attempts to validate the Gender radio button.
The error is that the objGender.length is undifined. Could you give me some help? Thanks.

 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"id" name must be unique one in whole HTML page. You just repeated 'txtGender' twice. Correct it.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After you fix your id problem, you can save yourself lot of code by using jQuery on your pages for things like this.

To check that one of the radio buttons is checked, the code would simply be:
 
Zhixiong Pan
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I removed the ID, and correct to . And then the code can work as I expect.
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic