Search code examples
jqueryvalidationdrop-down-menuradio-buttonjquery-tools

Dropdown box / radio button validation?


I'm using the jQuery tools (http://flowplayer.org/tools/demos/index.html) validator for my form and was wondering how to validate dropdowns and radio buttons?

Anyone had experience of implementing it?


Solution

  • In the documentation it says you can also use the required="required" attribute for SELECT elements, but it's not working for me either. I opted to use the custom validator function. Hope this works for you. It is pretty basic though, its missing some other considerations to make it more flexible.

    $.tools.validator.fn("select[required=required]", function(input, value) {
        // If the first item in the list is selected return FALSE
        return !input[0].options[0].selected;
    });