-1

My code is as followed:

 public function validateTIME($param) 
    {
        $item = $param->Item;  
        $value = $item->configValue->TextBox->Text;

            if(preg_match('^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$', "$value"))
            {
                echo 'nice';    
            }


            else{ echo "$value";
                  echo 'wrong';
                }   
    }

My question is why it does only go into the else part and not in the if one. The regex pattern is HH:MM (Hour=H Minute=M) and the pattern is ok.

GermanMech
  • 63
  • 1
  • 1
  • 12

1 Answers1

0

use like this with //

if(preg_match('/^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/', "$value"))
            {
                echo 'abcdefg';    
            }

for more

Umar Majeed
  • 313
  • 3
  • 15