Validate Alphanumeric String Script

Regular Expression Validate Alphanumeric String Script is use to validate alphanumeric character through regular expression.

Demo :



Check Alphanumeric String :  

Example :

Just type a alphanumeric string like this 123 and click Check button Is an alphanumeric string message will display otherwise type a 123? text at textbox and click check button Is not an alphanumeric string will display here.

Code :

Following code is use to Validate Alphanumeric String Script if you need to copy and use to your website.


<?php
  function validateAlphaNum($str)
  {
    return preg_match("/^[a-z0-9]*$/i", $str);
  }
  $alphanum = "123";
  echo validateAlphaNum($alphanum) ? "Is an alphabetic string" : "Is not an alphabetic string";
?>

In the above $alphanum variable is use to assign the numeric number. In the validateAlphaNum() function is use to check the alphabetic number through regular expression.

Free Download Script :

If you need Validate Alphanumeric String Script click and download from following link.

Download




Content