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 8255015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:23:21+00:00 2026-06-08T01:23:21+00:00

Background I’ve inherited an ancient web application that has input controls with custom behaviors

  • 0

Background

I’ve inherited an ancient web application that has input controls with custom behaviors defined with an old-fashioned HTC (HTML Component) script, e.g.:

<input name="txtFiscalYearEndDay" type="text" value="30" 
    maxlength="2" size="5" id="txtFiscalYearEndDay" class="Text1"       
    style="behavior:url(/path/js/InFocus.htc);" />

Here are the relevant parts of this HTC file to illustrate the issue:

<PUBLIC:COMPONENT tagName="InFocus">
<PUBLIC:METHOD NAME="setValid" />
<PUBLIC:ATTACH EVENT="ondocumentready" HANDLER="initialize" />
<SCRIPT LANGUAGE="javascript">

    function initialize() {
        // attaches events and adds CSS classes, nothing fancy
    }        

    function setValid(bInternal) {
        // checks some flags and changes a label
    } 

</SCRIPT>
</PUBLIC:COMPONENT>

So, nothing out of the ordinary so far. Additionally, I have some JS that runs on DOM-ready:

$(function() {
    txtFiscalYearEndDay_Validate(document.getElementById('txtFiscalYearEndDay'));
});

And the validation function:

function txtFiscalYearEndDay_Validate(el) {
    ...
}

Note: I’m not using $('#txtFiscalYearEndDay') because then I really can’t try to call setValid(true); on the element, nor do I want to have to do $('#txtFiscalYearEndDay')[0].setValid(true);.

The problem

At one point in the validation function, I’m attempting to call a method on the element, the one added by the HTC script:

el.setValid(true);

However, the IE debugger gets sad and complains that setValid() is not a function. Inspecting it in the debugger confirms this:

typeof el.setValid // "unknown"

Of course, once the page has completed rendering (or whatever period of time is needed for the document to actually be ready has passed), the validation function works as expected (because I’m calling the same validation function on change and blur events as well). That is, when the function is called outside of jQuery’s on-DOM-ready function, it works just fine.

Do any of you have any ideas at to what might be happening here? Is jQuery’s “ondomready” being registered before the HTC script’s “ondomready”? Can I somehow change that order?

I’m currently seeing this behavior in all versions of IE.

EDIT: WORKAROUND

I discovered a workaround. If you take the function call out of the jQuery ready function and throw it at the end of the page, it works (i.e.:)

...
    <script type="text/javascript">
        txtFiscalYearEndDay_Validate(document.getElementById('txtFiscalYearEndDay'));
    </script>
</body>
</html>
  • 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-06-08T01:23:23+00:00Added an answer on June 8, 2026 at 1:23 am

    The easiest workaround I could find was to move the validation function call out of the jQuery ready() callback and move it to the end of the page:

    ...
        <script type="text/javascript">
            txtFiscalYearEndDay_Validate(document.getElementById('txtFiscalYearEndDay'));
        </script>
    </body>
    </html>
    

    However, I found a more elegant solution. Because I seemingly need to wait for all page resources to be loaded, I simply needed to move the function call out of the jQuery ready() callback and instead put it in a window load() callback:

    $(window).load(function() { // instead of $(function() {
        txtFiscalYearEndDay_Validate(document.getElementById('txtFiscalYearEndDay'));
    });
    

    I’m using the latter so I can keep all of the JS code together.

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

Sidebar

Related Questions

Background: We're building an application that allows our customers to supply data in a
Background This is only my second PyQt4 project. Developing a Windows app that has
Background Developing a simple web application (Eclipse + JBoss + Apache Tomcat) to generate
Background: My coworker and I are maintaining a million-line legacy application we inherited. Its
Background I am currently creating an XNA application that utilizes LuaInterface so that I
Background: I would like to dismiss a modalView that I have presented earlier and
Background The main application where I work is based heavily on the MUMPS-esque Caché
Background: I have a css and a js that is used only by the
Background A lot of work has gone into optimizing database design, especially in the
Background info: We are currently 3 web programmers (good, real-life friends, no distrust issues).

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.