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?? Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
daveh33 Posted November 13, 2007 Author Share Posted November 13, 2007 That code works great - many thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.