Jump to content

[SOLVED] Check for non hexadecimal chars in a string


soadlink

Recommended Posts

This is probably very easy, I just cant think of a SIMPLE way to do it:

I'm looking for a php function that will search a string and output whether or not the string contains all hexadecimal characters or not.
So here is a sample:

[code=php:0]$string = 'abcdef1234567890z';
// function to check it
echo 'Your string does NOT contain only hexadecimal characters';[/code]


or if the string was 'abcdef1234567890',

[code=php:0]echo 'Your string contains all hexadecimal characters.';[/code]



Also on a side note, I need a simple way (javascript code maybe) to disable a "Submit" button in an html form until a certain number of characters have been entered into a text box that is located in that same form. Any help there would be good too (will most like need some javascript).

Thanks  8)
I tried your code but it didn't work. I used a few different test strings such as:  abc123, abc, 123... all turn out to say it doesn't contain only hex, when it does.
But I did try just a single "1" and it said it was all hex, which is true.

???

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.