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 *