I hope I am not the first one to push the limit :) because I don't think selection boxes are that rare :)
-----Original Message----- From: Yansheng Lin [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 06, 2003 9:16 PM To: 'Struts Users Mailing List' Subject: RE: RE: validating a html:select box Pushing the limit, eh:). How hard is it to write your own two line JavaScript. Besides, since it's a select box(not a combo), all the options are assumed to be valid from the beginning, why there is an invalid option there:). -----Original Message----- From: Erez Efrati [mailto:[EMAIL PROTECTED] Sent: August 6, 2003 1:39 PM To: 'Struts Users Mailing List' Subject: RE: RE: validating a html:select box For some reason, the javascript for intRange is not working if the property is a selection <html:select>. I looked in the javascript code (I am new to that still) but I saw that it only checks for the range if the field is a text or textarea. Is this true? How can I perform the client validation for selection boxes? Change the javascript? Erez -----Original Message----- From: David G. Friedman [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 06, 2003 5:22 PM To: Struts Users Mailing List Subject: Re: RE: validating a html:select box Erez, In that field validation, you can overload the sentence given back on that error. After <arg0 .../> add something like: <msg name="intRange" key="month.invalid"/> Then just add an application resource line such as: month.too.short=Please select a valid month. Or month.too.short=Please select a valid {0} to show the field name you put as arg0 in your validations xml configuration file. Regards, David -------Original Message------- From: Erez Efrati <[EMAIL PROTECTED]> Sent: 08/06/03 03:06 PM To: 'Struts Users Mailing List' <[EMAIL PROTECTED]> Subject: RE: validating a html:select box > > I guess I'd have to change the msg key to something else than the default message telling the value is out of range. What happens with html:radio? Is this also the way also to validate radio options? If no radio is selected (and I know this is off topic, well a bit) would the browser send a value? Thanks, Erez -----Original Message----- From: David G. Friedman [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 06, 2003 4:59 PM To: Struts Users Mailing List Subject: Re: validating a html:select box Erez, The Struts Validator has an intRange function. It's in the Validator User Guide: http://jakarta.apache.org/struts/userGuide/dev_validator.html Here's an example from that page so you can set your min & max as 1 & 12 to prevent the zero (label "month"?) from being submitted: <field property="integer" depends="required,integer,intRange"> <arg0 key="typeForm.integer.displayname"/> <arg1 name="range" key="${var:min}" resource="false"/> <arg2 name="range" key="${var:max}" resource="false"/> <var> <var-name>min</var-name> <var-value>10</var-value> </var> <var> <var-name>max</var-name> <var-value>20</var-value> </var> </field> -------Original Message------- From: Erez Efrati <[EMAIL PROTECTED]> Sent: 08/06/03 02:41 PM To: 'Struts Users Mailing List' <[EMAIL PROTECTED]> Subject: validating a html:select box > > I have a selection box with options where the first is valued 0 (=not selected) with some label saying: "month". How can I use the Struts validator to validate the user has actually chosen a value other than 0? Do I have to write one of my own? I wish the validwhen was around... By the way the 'birthMonth' is an int (not a string). Here is a snip of my page: <html:select property="birthMonth"> <html:option value="-1"> <bean:message key="date.month"/> </html:option> <c:forEach begin="1" end="12" var="m"> <html-el:option value='${m}'> <c:out value='${m}' /> </html-el:option> </c:forEach> </html:select> Thanks a lot, Erez --------------------------------------------------------------------- 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] --------------------------------------------------------------------- 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] --------------------------------------------------------------------- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]