An easy way could be to use
<html:option key="please select" value=""/>

with the minLength validation, using your own custom error message:

in validation xml:

  <field property="foo" depends="required, minlength">
 
<var><var-name>minlength</var-name><var-value>1</var-value></var>
          <msg name="required" key="Please Select an option from the
dropdown" resource="false" />
          <msg name="minlength" key="Please Select an option from the
dropdown" resource="false" />
    </field>

If you're using a bundle for error messages, replace the message with
the key and drop the resource="false"



-----Original Message-----
From: Frank Schaare [mailto:[EMAIL PROTECTED] 
Sent: 17 March 2004 17:31
To: Struts Users Mailing List
Subject: How to validate selects

Hi all,

i´m doing some selects like this:
<html:select property="foo">
   <html:option key="please select" value="null"/>
   <html:optionsCollection name="foo" property="bar"/>
</html:select>

Now, i have to validate, that the user has made his choice, which means 
that the 'foo' property is notNull.

Does anyone have an idea how to realise this in struts ?

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to