Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to check if a string is a valid hex color representation?
- var isOk = /^#[0-9A-F]{6}$/i.test('#aabbcc')
- var isOk = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test('#ac3') // for #f00 (Thanks Smamatti)
- function isHexaColor(sNum){
- return (typeof sNum === "string") && sNum.length === 6
- && ! isNaN( parseInt(sNum, 16) );
- }
Add Comment
Please, Sign In to add comment