Added error handling and refactored js

Added error handling to check if user is entering a digit 1-9.  Also
added html to display message when invalid input is entered.  Changed
js to use event delegation instead of adding event handler on every
input element.