Files
adanar/vendor/akdelf/akdmin/lib/validate.php
arlemp@selectel.ru c5003b00cf add files
2023-08-05 11:59:48 +03:00

26 lines
575 B
PHP

<?
function validate($txt, $vald_type)
{
switch (strtolower(trim($vald_type))) {
case 'notnull':
return ($txt == '') ? 0 : 1;
break;
case 'mail':
return (!eregi("^[a-z]+[a-z0-9_-]*(([.]{1})|([a-z0-9_-]*))[a-z0-9_-]+[@]{1}[a-z0-9_-]+[.](([a-z]{2,3})|([a-z]{3}[.]{1}[a-z]{2}))$", $txt)) ? 0 : 1;
break;
case 'phone':
return (!eregi("^[0-9]{3}-*[0-9]{3}-*[0-9]{4}$", $txt)) ? 0 : 1;
break;
case 'mysqldate':
return (!eregi("^[0-9]{4}-*[0-9]{2}-*[0-9]{2}$", $txt)) ? 0 : 1;
break;
default:
return 0;
}
}
?>