Lavina Yuan
asked on
onFocus doesn't work when the form is on blockui popup layer
I have a blockui popup layer where there is a form. I want to clear the text "Enter your email address" when the user clicks the input field. But when the popup layer opens, the text is gone. How to fix that issue? Thanks a lot! My code is as follows:
<input name="emailAddress" type="text" value="Enter your email address" onfocus="if (this.value == 'Enter your email address') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter your email address';}" />
The above code works perfectly fine if it's on a web page, but it doesn't work if it's a blockui layer.
Really appreciate your help.
<input name="emailAddress" type="text" value="Enter your email address" onfocus="if (this.value == 'Enter your email address') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter your email address';}" />
The above code works perfectly fine if it's on a web page, but it doesn't work if it's a blockui layer.
Really appreciate your help.
ASKER
Thanks so much HainKurt. I've figured it out - just add "focusInput: false" to blockui message to override the default which otherwise places the focus in the first available input field, making the text gone after the blockui opens.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Open in new window
here is a demo...
https://jsfiddle.net/k7kjqh4g/
actually I could not get what is not working here...