Implementing custom validator function for input fields