The ideal answer is to use the HTML5 and required attribute as part of the select element, for example:
<form method="post" action="processForm.php"> <label for="myLanguages">What languages can you program in?</label> <br> <select id="myLanguages" multiple required> <option value="C#">C# <option value="Java">Java <option value="PHP">PHP <option value="Perl">Perl <option value="Haskell">Haskell </select> <br> <input type="submit" value="Submit"> </form>
Yes, I know that these are not flags, but the ultimate functionality is exactly what you want. Unfortunately, neither IE 9 nor Safari 5 currently support the required attribute. However, Chrome 13 and FF 5 do. (Tested on Win 7)
source share