shotza Posted January 10, 2007 Share Posted January 10, 2007 Hi folksI'm very new at php and writing code in general so please be gentle with me :)I'm trying to write an if statement that will check for numeric input unfortunatley the code isnt trapping any text input. The statement is as follows: if (!preg_match('/[[:^digit:]]/', $seconds)) { echo "<h1>Laptime must contain numeric values only! </h1> <p>Please hit the <b>Back Button</b> on your browser to re-enter information"; exit(); }#end ifAny pointing out of stupid mistakes would be greatly appreciated! Link to comment https://forums.phpfreaks.com/topic/33603-preg_match-not-doing-much/ Share on other sites More sharing options...
effigy Posted January 10, 2007 Share Posted January 10, 2007 POSIX bracket-expressions are not valid in PCRE; try [tt]/^\d+$/[/tt] to match all digits. Link to comment https://forums.phpfreaks.com/topic/33603-preg_match-not-doing-much/#findComment-157440 Share on other sites More sharing options...
shotza Posted January 10, 2007 Author Share Posted January 10, 2007 That worked a treat - very much appreciated :) Link to comment https://forums.phpfreaks.com/topic/33603-preg_match-not-doing-much/#findComment-157481 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.