Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6627659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:02:24+00:00 2026-05-25T22:02:24+00:00

I have an html form which uses jquery focus and blur in order to

  • 0

I have an html form which uses jquery focus and blur in order to clear and restore some preset field text. However, the form is in a modal dialog which can be hidden and shown using jquery hide() and show(). However, when the form is hidden, it is throwing a javascript error:

an invalid form control with name = 'email' is not focusable

I’m assuming this is because the form is hidden and can’t be accessed. Is there a way to force a blur event? Or some way to resolve this error? Here’s my code:

$j('.dField').focus(function(){
    clearInput($j(this)[0]); //The [0] seems to be necessary to retrieve the element at the DOM object level
});
$j('.dField').blur(function(){
    restoreInput($j(this)[0]);
});

function clearInput(textField) {
    if (textField.value == textField.defaultValue) {
        textField.value = "";
     }
}

//Restores the default value
function restoreInput(textField){
    if (textField.value == ""){
        textField.value = textField.defaultValue;
    }
}

$j('#dFormBack').click(function(){
        $j('#dContentContainer').show();
        $j('#vehicle_form').hide();
    });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:02:25+00:00Added an answer on May 25, 2026 at 10:02 pm

    You can activate the function inside the blur event listener, instead of trying to initiate a blur event.

    restoreInput($j(".dfield")[0]);
    

    A side note, your first lines can be written more efficiently:

    $j('.dField').focus(function(){
        clearInput(this);
    }).blur(function(){
        restoreInput(this);
    });
    

    this in the event handler refers to the DOM element to which the event listener is attached. It’s unnecessary to wrap this inside a JQuery wrapper and get the DOM element again using [0].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a an HTML form which contains the YAHOO rich text editor on
I have a HTML form which uses special characters in ids ( :,-,_ ).
I have a simple contact form which uses jquery to post to a php
Hey all, I have an HTML form on my website which currently only uses
I have a live preview form: http://davidwalsh.name/jquery-comment-preview Which uses jquery to display the preview
I have a form which uses ajax for data submitting. Here is the html:
I have an index.html file which I want to run some jQuery when it
I have a html form which have a select list box from which you
I have this html form which has options: <tr> <td width=30 height=35><font size=3>*List:</td> <td
I have an HTML form generated by JSF which maps an input element to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.