Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validating a JSP

 
Hari Dhanakoti
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using a sample jsp page to work on the javascript validation. My form components resembles as such...



If i access form components as such then it gives alert as undefined.


If i access form components as such then it gives alert with the first component value.



What should i do for validating the jsp...
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

1) there is a loop right so every time same name onlt asigned to the input tag ..so if you want to take 2 nd value use
---------------------------------------------------

alert(document.validForm.first1[1].value);...etc
------------------------------------------------------

2) if you want to use getElementById then you have to set new name for every iteration ...because if you want to use getElementById then field name should uniqu other wise it will give first matching value ........

hint:

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what happend ? post is lengthy!(big wide)
 
Hari Dhanakoti
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi seetharaman ,

Thanks for your reply.
The above mentioned case works well with checkboxes.
Incase of using the radio buttons i would like to have a unique name to represent.

So how do i handle it in case of radio buttons.
Any suggestions?
 
Hari Dhanakoti
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I got the things working...

Thanks for your reply.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic