Is it possible to set limit in multiple selection dropdown list?

I am using a multiple selection drop-down list in my site.This is working properly and we can select more than one options from that list.But I want select only 3 options from that list.Is it possible to set limit for that??

I am using the code from


use jQuery and following click function, it will help

    $('#slectboxid option').click(function() 
        var items = $(this).parent().val();
        if (items.length > 3) {
                       alert("You can only select 3 values at a time");

Edit: use .prop() instead of .removeAttr(),.removeAttr() is deprecated in newest jQuery libraries

In formsubmit.php change line 3 with the following line :

if (isset($options) && count($options) == 3) {

Then modify line 26 with the following :

echo 'Please select exactly 3 options';

Need Your Help

Getting milliseconds accuracy current time in Qt

c++ qt qtime

Qt documentation about QTime::currentTime() says :