added prevent default to event listeners, cleaned up input validation logic