This function works in Firefox, Chrome, IE9. Doesn’t work in Opera.
function isValidHex(hex) { alert(hex);
var strPattern = /^#([0-9a-f]{1,2}){3}$/i; alert(strPattern.test(hex));
return strPattern.test(hex);
}
The hex going in is the same. The result of strPatter.test returns false in Opera and true in Firefox.
Tested.
#000000
#ffffff
Any ideas?
This regex is incorrect.
#1234would be correct too in this regex. User the regex/^#([a-fA-F0-9]{3}|[a-fA-F0-9]{6})$/.