Setting a limit for <select mutiple>

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Setting a limit for <select mutiple>

Post by kendall »

Hello,

Can you use javascript to define the max number of options to select from a menu/list that allows for multiple select options?

e.g

lets say that i have 20 options for a select list i want to only select five

Kendall
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

you could use the onSelect-event to call a function which checks the total number of items selected. If too many, have JS de-select the one with the focus.
Post Reply