[thelist] hex colour check (javascript)

Simon Hibbard shibbard at seri.co.uk
Tue Sep 24 02:51:00 CDT 2002


Hi all,

Currently have a form allowing users to enter a hex colour value which is used to update
various styles. What I'm after is a way to validate that what they enter, i check the length
and the fact that it starts with '#', but any ideas on how to check the hex is valid i.e.
#000000 to #FFFFFF.

I tried using 'parseInt(val,16)' and to check in 'isNan' but such strings as FFFFFS still do
not return 'NaN'.

I suppose i could check each letter is one of A,B,C,D,E,F - surely there is a better way?

Ideas?


Thanks,

Simon.


The mail message has been scanned by MAILsweeper
for content analysis.




More information about the thelist mailing list