'isvalidInput' modified to use regex