I\'ve written a jQuery plugin that accepts css colors for some of its parameters.
I want to validate them. If it was just a hex or rgb value I could do that with a r
You could simply set the color to a dummy element and then check if the element's value is something other than white.
colorToTest = 'lime'; // 'lightgray' does not work for IE
$('#dummy').css('backgroundColor', 'white');
$('#dummy').css('backgroundColor', colorToTest);
if ($('#dummy').css('backgroundColor') != 'rgb(255, 255, 255)' || colorToTest == 'white') {
alert(colorToTest+' is valid');
}