added input validation javascript