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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:14:14+00:00 2026-06-11T21:14:14+00:00

I cannot figure out what I’m doing wrong. validateForm() does not seem to execute

  • 0

I cannot figure out what I’m doing wrong. validateForm() does not seem to execute from an onsubmit. Here is validateForm()

function validateForm() {
    var amt = IsNumeric(document.forms["InvGenPay"]["Amount"].value);

    alert(amt);

    if (amt == false)
    {
        alert("placeholder to avoid scrolling.");
        return false;
    }
    else
    {
        return true;
    }
}

function IsNumeric(strString)
{
    //  check for valid numeric strings  
    var strValidChars = "0123456789.";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return false;

    //  test strString consists of valid characters listed above
    for (i = 0; i < strString.length && blnResult == true; i++)
    {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
            blnResult = false;
        }
    }

    if (0 > parseFloat(strString))
    {
        return false;
    }
    else
    {
        return blnResult;
    }
}

Here is the form with onsubmit:

<script type="text/javascript" language="JavaScript1.2">
document.write('<form name="InvGenPayDonation" action="'+PostURL+'" onsubmit="return validateForm();" method="POST">');
</script>


<input type='text' name='DonationAmount' value="0.00">
In honor of <span style="color: #FF0000"><br />
<input type='text' name='TransDesc' id='TransDesc' value="" >
<input type="submit" value="Next">
</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-11T21:14:16+00:00Added an answer on June 11, 2026 at 9:14 pm

    Your biggest issue is that you don’t have the right form name (or the right field name for that matter) in your validation code.

    var amt = IsNumeric(document.forms["InvGenPay"]["Amount"].value);
    

    vs

    '<form name="InvGenPayDonation" action="'+PostURL+'" 
    

    Full, working code:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"         
       "http://www.w3.org/TR/html4/strict.dtd">
    <head>
      <title>Sampe file</title>
    
      <script>
    function validateForm() {
        // Badly named variable, since this is actually a boolean of 'IsNumeric'
        var amt = IsNumeric(document.forms["InvGenPayDonation"]["DonationAmount"].value);
    
    
        // Can be simplified as simply:
        //return amt;
        alert('Amt = ' + amt);
    
        if (!amt)
        {
            alert("placeholder to avoid scrolling.");
            return false;
        }
        else
        {
            return true;
        }
    }
    
    function IsNumeric(n) {
      // Shamelessly stolen from: 
      // http://stackoverflow.com/questions/18082/validate-numbers-in-javascript-isnumeric
      return !isNaN(parseFloat(n)) && isFinite(n);
    }
    
    </script>
    
    <body>
    <form name="InvGenPayDonation" action="#"
            onsubmit="return validateForm();" 
            method=POST>
    
    
    <input type='text' name='DonationAmount' value="0.00">
    In honor of <span style="color: #FF0000"><br />
    <input type='text' name='TransDesc' id='TransDesc' value="" >
    <input type="submit" value="Next">
    
    <script>
      // Assigned for testing purposes
      var  PostURL = "#"
      document.forms.InvGenPayDonation.action = PostURL;
    </script>
    </form>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cannot figure out what I am doing wrong here. The permissions for the
I cannot figure out what is wrong with this fql.multiquery and cannot seem to
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
still cannot figure out what I am doing wrong. Just trying to get a
I cannot figure out why my calculation is not working. I am doing for
I cannot figure out this positioning problem in Firefox. It doesn't seem to follow
I cannot figure out how to convert this code from C# to VB.net. It
I cannot figure out how to get rid of errors that should not be
I cannot figure out why this segment gives unresolved overloaded function error (gcc version
I cannot figure out why it's not working. I run the project on the

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.