On 10 Jul 2012, at 11:21 PM, Annet wrote: > I have a table in which users enter hexadecimal values to set colors and > background-colors. I'd like to validate the values the user enter, > requires=IS_HEX() would be ideal, but there is no such validator. I wonder > whether any one has done hexadecimal validation and could provide me with a > validator.
IS_MATCH(r'([\da-fA-F]{3}|[\da-fA-F]{6})', strict=True) That's assuming you want a web color, restricted to 3 or 6 hex digits. You could of course edit it as required.