Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript check if string is valid hex color

// Match exactly 3 characters 1 or 2 times
var reg=/^#([0-9a-f]{3}){1,2}$/i;
console.log(reg.test('#ABC')); //true
console.log(reg.test('#AABBCC')); //true
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #check #string #valid #hex #color
ADD COMMENT
Topic
Name
9+1 =