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

  • Home
  • SEARCH
  • 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 692321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:38:18+00:00 2026-05-14T02:38:18+00:00

I hope I can explain this right I have two input fields that require

  • 0

I hope I can explain this right I have two input fields that require a price to be entered into them in order for donation to go through and submit.

The problem that I am having is that I would like the validation process check to see if one of the two fields has a value if so then proceed to submit. If both fields are empty then alert.

This is what I have in place now after adding some of the input i received earlier today:

 function validate_required(field,alerttxt)
{ 
with (field) 
{ 
    if (value==null||value=="") 
    {
        alert(alerttxt); return false;
    } 
    else 
    {
        return true;
    } 
} 
}

function validate_form(thisform)
{
with (thisform)
{

    if (validate_required(billing_name_first,"You must enter your first name to donate")==false)
    {billing_name_first.focus();return false;}

    else if (validate_required(billing_name_last,"You must enter your last name to donate")==false)
    {billing_name_last.focus();return false;}

    else if (validate_required(billing_address_street1,"You must enter your billing street address to donate")==false)
    {billing_address_street1.focus();return false;}

    else if (validate_required(billing_address_city,"You must enter your billing address city to donate")==false)
    {billing_address_city.focus();return false;}

    else if (validate_required(billing_address_state,"You must enter your billing address state to donate")==false)
    {billing_address_state.focus();return false;}

    else if (validate_required(billing_address_zip,"You must enter your billing address zip code to donate")==false)
    {billing_address_zip.focus();return false;}

    else if (validate_required(billing_address_country,"You must enter your billing address country to donate")==false)
    {billing_address_country.focus();return false;}

    else if (validate_required(donor_email,"You must enter your email address to donate")==false)
    {donor_email.focus();return false;}

    else if (validate_required(card_number,"You must enter your credit card number to donate")==false)
    {card_number.focus();return false;}

    else if (validate_required(card_cvv,"You must enter your credit card security code to donate")==false)
    {card_cvv.focus();return false;}

    else if (validate_required(input1,"Need to enter a donation amount to continue")==false && validate_required(input2, "Need to enter a donation amount to continue")==false) 
    {
        input1.focus();
        return false;
    }
}
}

This works fine… other than the fact that I get a message that reads error undefined… which i click ok about 2 times then I get the correct alert and instead of allowing me to correct the problem in IE7 and IE8 the form just processes.

Thanks guys any help would do

Matt

  • 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-14T02:38:19+00:00Added an answer on May 14, 2026 at 2:38 am

    If I am understanding correctly, you only want to do the alert if both of the inputs are empty. If that’s the case here’s a refactoring of your code that will handle that.

    function validate_required(field) 
    { 
        with (field) 
        { 
            if (value==null||value=="") 
            {
                return false;
            } 
            else 
            {
                return true;
            } 
        } 
    } 
    function validate_form(thisform) 
    { 
        with (thisform)
        { 
            if (validate_required(input1)==false && validate_required(input2)==false) 
            {
                alert('Need a donation to continue');
                input1.focus();
                return false;
            }
        } 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 364k
  • Answers 364k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The error message says it all. The as operator can… May 14, 2026 at 3:43 pm
  • Editorial Team
    Editorial Team added an answer I have not used this so cannot vouch for it… May 14, 2026 at 3:43 pm
  • Editorial Team
    Editorial Team added an answer Fixed my own problem: The answer is the "ticks" declaration.… May 14, 2026 at 3:43 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.