View Full Version : Check color hex code with Javascript

06-15-2007, 03:53 PM

How can I validate a form field if the visitor has entered a valid hex color code between #000000 and #FFFFFF?

Thanks in advance.

Philip M
06-15-2007, 04:01 PM
if (/^(#[A-F0-9]{6})$/i.test(lstr.value)) { // valid hex code

You can test your regular expressions at: http://www.ogauge.co.uk/regextester.html

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum