This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Struts and the fly likes JavaScript Validation in Struts for Drop Down List Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "JavaScript Validation in Struts for Drop Down List" Watch "JavaScript Validation in Struts for Drop Down List" New topic
Author

JavaScript Validation in Struts for Drop Down List

dimpsonu arora
Ranch Hand

Joined: Aug 13, 2003
Posts: 51
Hi All,
I am using client side javascript validation using struts in my struts project. I have a form that contains Name, age, address, country, state fields. I have done validation for name age and address but country and state are drop down list and validation for these is not available in validation-rules.xml. All I need to is to show a alert while submitting the form if user does not choose a country and In Country drop down box, "select a country" is appearing. How to write my own validation and where? Thanks in advance.
Kerry Wilson
Ranch Hand

Joined: Oct 29, 2003
Posts: 251
You can write your own validation rules in any class, but I think you should just use the validwhen rule. Just put validwhen in the depends list and set variable called test = (*this* != "Select Country...") or make the field required and put value of Select Country option to empty string.


http://www.goodercode.com
SCJP 1.4
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: JavaScript Validation in Struts for Drop Down List
 
Similar Threads
how jsf component get the value from backing bean instead of submitted value after validation error
select values for second drop down
Struts2 label tag - key attribute is being replaced with actual value?
A4j:Support Problem
submit thru javascript