Regular Expression Validate Float Number Script

Regular Expression Validate Float Number Script is use to validate float number through regular expression.

Demo :



Type Number :  

Example :

Is a float number : 123456.506
Is not a float number : 12a3456.506

Code :

Following code is use to regular expression validate float number script if you need to copy and use to your website.


<?php
  function validateFloat($str)
  {
    return preg_match("/^-?([0-9])+([\.|,]([0-9])*)?$/", $str);
  }
  $number = '12a3456.506';
  echo validateFloat($number) ? "Is a float number" : "Is not a float number";
?>

In the above validateFloat() function is validate a float number. In the preg_match() function is use to validate regular expression condition.

Free Download Script :

If you need regular expression validate float number script click and download from following link.

Download




Content