You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Adam Lipscombe <ad...@expensys.com> on 2006/03/29 18:56:04 UTC

How to restrict number of chocies in multiple html:select

Folks,

With an <html:select .. multiple="true"> is it possible to restrict the
number of selections that can be made?
To say 2 or 3?

OK I could validate the number selected in the actionform or in javascript
but I would really like to tell the combo box to only allow N selections.



TIA -Adam


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] Re: How to restrict number of chocies in multiple html:select

Posted by Dave Newton <ne...@pingsite.com>.
Dave Newton wrote:
> Adam Lipscombe wrote:
>   
>> OK I could validate the number selected in the actionform or in javascript
>> but I would really like to tell the combo box to only allow N selections.
>>   
>>     
> AFAIK this is completely browser-controlled as it's a standard HTML
> select tag. You would need to use JavaScript.
>   

Whoops, meant to add that you could validate server-side by looking at
the length of the array and writing a custom validator (one may already
exist for this; I don't recall).

But I don't believe that HTML supports a "max number of selections"
attribute.

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


[OT] Re: How to restrict number of chocies in multiple html:select

Posted by Dave Newton <ne...@pingsite.com>.
Adam Lipscombe wrote:
> With an <html:select .. multiple="true"> is it possible to restrict the
> number of selections that can be made?
> To say 2 or 3?
>
> OK I could validate the number selected in the actionform or in javascript
> but I would really like to tell the combo box to only allow N selections.
>   

AFAIK this is completely browser-controlled as it's a standard HTML
select tag. You would need to use JavaScript.

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org