Skip to content
Advertisement

Javascript function not working on blur event

I have written a function which I expect should check if a text field is empty and if so should bring the focus back on it. The check is done when a user moves away from the text field (on blur). Unfortunately, the code isn’t working. Why is it so? I am using playframework. The issue is in Javascript code.

JavaScript

Advertisement

Answer

suggestion from Ibrahim worked – You should put firstName = document.get… and firstName.addEve… inside the load event listener (setup function)! ANYTHING THAT HAS SOMETHING TO DO WITH DOM MUST TO WAIT FOR THE DOM TO BE LOADED

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement