Use loop to simplified the text field event listener