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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:21:06+00:00 2026-05-25T10:21:06+00:00

Very simple error here, I’m sure, but basically I have a form with id

  • 0

Very simple error here, I’m sure, but basically I have a form with id formID and im calling it like so:

<script type="text/javascript">
    function redvalidate() {
        var form = document.getElementById("formID")
        var fields = form.getElementsByClassName("validate"),

And I’m getting the error: form is null

Can anyone spot the error?

(PS calling it onsubmit of a form)

UPDATE
Ok so basically i have two onsubmit for one form which oviously doesnt work. So what I am doing is calling this function from within another…

Heres the form tag:

<form name="purchaseform" id="formID" onSubmit="RememberFormFields('purchaseform','name,email,ship_to,phone_extension,pi_name');" action="process.php" method="post" enctype="multipart/form-data">

And heres RememberFormFields:

    <script type="text/javascript">
function RememberFormFields(form,list)
{
redvalidate()

...etc... rememberformfields function ...et.c..
  • 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-25T10:21:06+00:00Added an answer on May 25, 2026 at 10:21 am

    Assuming you have the html <form id="formID"... somewhere on your page, you simply need to defer the loading of your javascript until after the DOM is ready. You’re trying to get the ID from an element that hasn’t been applied to the DOM yet and therefore JavaScript sees it as NULL.

    There are many ways to achieve this. You can put all your JS near the </body> tag, you can use Google’s suggested deferred javascript loading practice which appends all your JS to the <head> from the bottom of the body.

    This is one reason JQuery is so handy, because you can wrap your code in a $(document).ready(function(){}); block so any DOM-manipulating scripts will always work because they wait until the DOM is created before they fire. It achieves this by looking for the “DOMContentLoaded” event in modern browsers and has a doScrollCheck() function for IE which tries to scroll the body over and over – if it is scrollable, they know it’s good to go. You can easily replicate this practice if you don’t want to load JQuery just for this.

    JQuery’s DOM ready check:

    if ( document.addEventListener ) {
        DOMContentLoaded = function() {
            document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
            jQuery.ready();
        };
    
    } else if ( document.attachEvent ) {
        DOMContentLoaded = function() {
            // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
            if ( document.readyState === "complete" ) {
                document.detachEvent( "onreadystatechange", DOMContentLoaded );
                jQuery.ready();
            }
        };
    }
    
    // The DOM ready check for Internet Explorer
    function doScrollCheck() {
        if ( jQuery.isReady ) {
            return;
        }
    
        try {
            // If IE is used, use the trick by Diego Perini
            // http://javascript.nwbox.com/IEContentLoaded/
            document.documentElement.doScroll("left");
        } catch(e) {
            setTimeout( doScrollCheck, 1 );
            return;
        }
    
        // and execute any waiting functions
        jQuery.ready();
    }
    
    return jQuery;
    
    })();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My problem seems to be very simple but I'm stuck here. I have a
I have some very simple code but I am getting the aforementioned error, any
very simple problem here... but I can't work it out. I have a simple
So basically what I have set up here is a very simple and generic
OK, I'm having this very very simple error, but I can't figure it out
Here's my hypothetical example. I have a very simple WPF window with a one
I have a very simple question. I'd like to use a where clause after
I just wrote a very simple Expect script for wrapping around rsync, but it
I have a very simple agent, basically just the required Agent_OnLoad method signature. If
Trying to perform a very simple task here. I have an <ol> that contains

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.