Check from textfield if name is valid and not empty using javascript

Check from a html textfield form if input is a valid name (no numbers) and it is not empty

 

   
      //returns true if name is valid and not empty
    function isValidName(name){
        var matches = name.match(/\d+/g);
        //valid name
        if(name=="" || matches != null){
            return false;
        }else{
            return true;
        }
    }
   

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>