Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
function hd_number_isprice($string) {
$tot_dot = substr_count($string, ".");
$tot_comma = substr_count($string, ",");
// - ! - if decimal
if (($tot_dot == 1 OR $tot_comma == 1) AND $tot_dot + $tot_comma < 2) {
if (preg_match("^[0-9]+[0-9]+[0-9]$", str_replace(".", "", str_replace(",", "", $string)))) {
return true;
} else {
return false;
}
// - ! - if not decimal
} else {
if (preg_match("^[0-9]+[0-9]+[0-9]$", $string)) {
return true;
} else {
return false;
}
}
}
function hd_number_isprice($string) {
$tot_dot = substr_count($string, ".");
$tot_comma = substr_count($string, ",");
// - ! - if decimal
if (($tot_dot == 1 OR $tot_comma == 1) AND $tot_dot + $tot_comma < 2) {
if (ereg("^[0-9]*$", str_replace(".", "", str_replace(",", "", $string)))) {
return true;
} else {
return false;
}
// - ! - if not decimal
} else {
if (ereg("^[0-9]*$", $string)) {
return true;
} else {
return false;
}
}
}
if (($tot_dot == 1 OR $tot_comma == 1) OR ($tot_dot + $tot_comma < 2))
if (isset($_POST['number'])){
$output = trim($_POST['number']);
$pattern = "/^[-+]?([0-9]*[,\.])?[0-9]+$/";
if ( preg_match($pattern, $output)) { echo "match"; } else {echo "no match";};
}
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method=post>
<input name="number" type="text" />
<input type="submit" name="submit" value="test"/>
</form>