Can you help me to validate if my input number is valid.
It can be a whole number It can also be a decimal number but interval is 0.5, So 0.5, 1.5 , 2.5 is ok but .2,1.3,2.6 is not valid.
if ((preg_match('/^\d+\.\d+$/',$bkpoints)) || (preg_match('/^\.\d+$/',$bkpoints)))
{ {
if ($bkpoints % 0.5 !== 0)
{
$this->form_validation->set_message('is_bk_decimal','Bk points decimal value should be incremented by 0.5');
return false;
}
}
return true;