daveh33 Posted November 13, 2007 Share Posted November 13, 2007 I have a variable $t - I need to validate it so it allows: - 32-digits, alpha numeric and in the range A-F and 0-9. All letters will be in CAPITALS. and if not display an error message - how do I do this?? Link to comment https://forums.phpfreaks.com/topic/77154-solved-validating-variable/ Share on other sites More sharing options...
revraz Posted November 13, 2007 Share Posted November 13, 2007 Do an IF Statement for each requirement. Verify against length, type and range. Caps is really not an issue because you can just convert everything to uppercase. Doing something with HEX? Link to comment https://forums.phpfreaks.com/topic/77154-solved-validating-variable/#findComment-390632 Share on other sites More sharing options...
Orio Posted November 13, 2007 Share Posted November 13, 2007 Simple regular experssion: <?php if(!preg_match("/^[A-F0-9]{32}$/", $t)) echo "Invalid"; ?> Orio. Link to comment https://forums.phpfreaks.com/topic/77154-solved-validating-variable/#findComment-390633 Share on other sites More sharing options...
daveh33 Posted November 13, 2007 Author Share Posted November 13, 2007 That code works great - many thanks Link to comment https://forums.phpfreaks.com/topic/77154-solved-validating-variable/#findComment-390636 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.