php pattern check code wanted? 10pts for best answer?

  • Thread starter Thread starter <prantik>
  • Start date Start date
P

<prantik>

Guest
i want a code than checks the pattern and tell me if there a alphabet or alpha numeric is in the whole string,
i have done this:
<?
if(0 == preg_match_all ("|[0123456789_]|", "".$subject."", $string_out_array))
{
echo "only numeric allowed";

}
else
{
echo "done";
}

?>

this works fine if i enter a alphabet before a numeric I.e, a11(output "only numeric allowed") or only numeric I.e, 11(output "done") but not whens i enter a alphabet after the numeric I.e, 11a (output "done") but the output should be" only numeric allowed".

in short i want only numeric tobe entered,if any other character is entered then a error message should be displayed and vise-verse..please provide the code.
 
Back
Top