johnsmith153 Posted October 11, 2008 Share Posted October 11, 2008 Title says it all. My form sends a colour the user has chosen, I need to fail it if it is not a valid hex value. Link to comment https://forums.phpfreaks.com/topic/128031-solved-script-to-check-if-input-is-valid-hex-value/ Share on other sites More sharing options...
Orio Posted October 11, 2008 Share Posted October 11, 2008 <?php if(!preg_match("/#?[0-9A-F]{6}/i", $str)) //With or without # echo "Invalid! must 6 valid hex digits!"; ?> Orio. Link to comment https://forums.phpfreaks.com/topic/128031-solved-script-to-check-if-input-is-valid-hex-value/#findComment-662972 Share on other sites More sharing options...
johnsmith153 Posted October 11, 2008 Author Share Posted October 11, 2008 Perfect, cheers. Link to comment https://forums.phpfreaks.com/topic/128031-solved-script-to-check-if-input-is-valid-hex-value/#findComment-662975 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.