php - !preg_match for letters not working -


i developing website in use !preg_match("~/^[a-za-z ]*$/~",$name) when user write his/her name in html form field letters allow write if number write message appears "only letter allowed".... takes both numbers , letter. do??? here code:

<?php     $nerr = $naerr = $cerr =  "";     $id = $name = $color =  "";      if (isset($_post["submit"])) {           $id = $_post["id"];          $name = $_post["name"];           $color = $_post["color"];          if (!preg_match("[0-9]",$id))           {            $nerr = "only number allowed";           }            else if (!preg_match("~/^[a-za-z ]*$/~",$name))           {            $naerr = "only letters allowed";           }            else if (!preg_match("~/^[a-za-z ]*$/~",$color))          {            $cerr = "only letters allowed";           }         }     ?> 


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -