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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:18:47+00:00 2026-06-08T03:18:47+00:00

I have the following basic javascript function that I call when an onClick event

  • 0

I have the following basic javascript function that I call when an onClick event occurs

function testMe() {
    var oForm = document.forms["ExampleForm"]["First Name"].value;
    console.log(oForm);
    if (oForm == "") {
        window.alert("This is a test");
    }
    return false;
}

However each time I click on the button, I get the error Cannot read property "First Name" of undefined javascript in the console. The form element First Name exists and does the form name ExampleForm

What am I overlooking or doing wrong?

EDIT 0

Although the example I have running at http://jsfiddle.net/3Ayd8 works it does not work when I run the same code on a page on an internal website.

EDIT 1

Here is the output of console.log(document.forms)

<form method="post" action="sample.aspx" id="form">

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form'];
if (!theForm) {
    theForm = document.form;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>

<script type="text/javascript">
    //<![CDATA[

function NewDocument(parentNodeId, classId){ 
    if (parent != window) { 
        parent.NewDocument(parentNodeId, classId); 
    } else { 
        window.top.document.location = '/default.aspx?section=content&action=new&nodeid=' + parentNodeId + '&classid=' + classId; 
    } 
}
function NotAllowed(action){ 
    if (parent != window) { 
        parent.NotAllowed('', action); 
    } else { 
        window.top.document.location = '/default.aspx?section=content&action=notallowed&subaction=' + action; 
    } 
}
function DeleteDocument(nodeId) { 
    if (parent != window) { 
        parent.DeleteDocument(nodeId); 
    } else { 
        window.top.document.location = '/default.aspx?section=content&action=delete&nodeid=' + nodeId; 
    } 
}
function EditDocument(nodeId) { 
    if (parent != window) { 
        parent.EditDocument(nodeId); 
    } else { 
        window.top.document.location = '//default.aspx?section=content&action=edit&nodeid=' + nodeId; 
    } 
}
//]]>
<input type="hidden" name="vmode" id="vmode" value="2">
</div>
<script src="/GetResource.ashx?scriptfile=%2fCMSScripts%2fcmsedit.js" type="text/javascript"></script>
<script src="/ScriptResource.axd?d=aK015nKOf8Jw44OCiklcSydFiWaSIB9l6ZwdCQaMAWlevtaFiOw7Urzac1pIZ9Rs0&amp;t=34d147fd" type="text/javascript"></script>
<script src="/ScriptResource.axd?d=aK015nKOf8Jw44OCiklcSydFiWaSIB9l6ZwdCQaMAWm_idfkOBcdRXBrkc0cxAR10&amp;t=34d147fd" type="text/javascript"></script>
<div class="aspNetHidden">

    <input type="hidden" name="__SCROLLPOSITIONX" id="__SCROLLPOSITIONX" value="0">
    <input type="hidden" name="__SCROLLPOSITIONY" id="__SCROLLPOSITIONY" value="0">
</div>
    <div id="manPortal" style="background:none;">
    <div id="CMSHeaderPad" style="height: 22px; line-height: 0px; "></div><div id="CMSHeaderDiv" style="position: fixed; top: 0px; left: 0px; right: 0px; bottom: auto; z-index: 10000; overflow: hidden; width: 100%; ">
<script type="text/javascript">
    //<![CDATA[
if ( (parent != null) && (parent.IsCMSDesk) ) { infoElem = document.getElementById('manPortal_pnlPreviewInfo'); if (infoElem) {if ( infoElem.style ) { infoElem.style.display = 'none'; } else { infoElem.display = 'none'; } }}
//]]>
</script><!-- -->
    </div>
</div><script type="text/javascript">
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('manScript', 'form', [], [], [], 90, '');
//]]>
</script>


<script type="text/javascript" src="/jquery-1.4.2.min.js"></script>
 <script type="text/javascript" src="/jquery-ui-1.8.10.custom.min.js"></script>
<script type="text/javascript" src="/plugins.js"></script>
<script type="text/javascript" src="/script.js?v=0.4"></script>

    <div class="zoneMainContent">
<div class="one-col-layout">
    <div class="col-one">
    <script type="text/javascript">
function testMe() {
    console.log(document.forms);
    console.log(document.getElementById("ExampleForm"));
    return false;
}
</script>

    <input id="FirstName" name="FirstName" type="text" value=""> <input name="submit" onclick="return testMe();" type="submit" value="submit">

    </div>
</div>
        <div style="clear:both;line-height:0px;height:0px;"></div>
    </div>
</div></form>
  • 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-08T03:18:49+00:00Added an answer on June 8, 2026 at 3:18 am
    1. Instead of “First Name” you should use “FirstName”. This was not the main issue, because “ExampleForm” was not found in the document.

    2. If you have “ExampleForm” in an iFrame and you try to reach it from the outer document then your attempt will be unsuccessful, you need to reach “ExampleForm” from the page inside the iFrame in this case

    3. If your page is inside an iframe and you try to reach “ExampleForm” which is in the outer document then you can use the window.parent property

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

Sidebar

Related Questions

I have the following basic function: <script type=text/javascript> function Form_Data(theForm) { var t=1; while
I have the following Javascript between tags in a template: YAHOO.util.Event.addListener(window, load, function() {
I am doing some basic form validation. I have the following JavaScript function: function
I have a basic web service that returns the following object as JSON: public
I'm new to javascript/jquery. I have the following basic code and I keep receiving
i have the following basic script to make an api call to vimeo and
Say I have the following basic if-statement: if (A ~= 0) % do something
If I have the following basic C++ program: #include <iostream> using namespace std; class
I have come across the following basic Tree conflict: Local add, incoming add upon
I have the following assignment: Implement a basic shopping basket without using any predefined

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.