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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:52:47+00:00 2026-05-17T14:52:47+00:00

With the help of Nick Craver, I am now able to have two forms

  • 0

With the help of Nick Craver, I am now able to have two forms with two separate PHP processing scripts use one submit button. I need to expand on this a little bit. I need it to work so that if you have a value in input#retUser it submits with formOne action. If you have a value in #fname && #lname && #email1 it submits with formTwo Action. If there is NO value in any field return an alert.

  <form name="returning" method="post" action="PHPscript1.php">
  <label>Are you a returning user? Please Enter Your Key</label>
  <input type="text" name="retUser" id="retUser" />
  </form>
  </div>

  <div id="formTwo">
  <form name="newUser" method="post" action="PHPscript2.php">
  <label>Are you a new user? Register here</label>
  <label>First Name</label>
  <input type="text" name="fname" id="fname" />
  <label>Last Name</label>
  <input type="text" name="lname" id="lname" />
  <label>Email</label>
  <input type="text" name="email1" id="email1" />
  </form>
  </div>

  <div id="submitContain">
  <input type="submit" id="sbtBtn" value="submit" />
  </div>

I split the submit function into two separate ones so I can add validation for each later.

$("#formOne").submit(function() {
alert("Trying to submit to: formOne");
return false;
});

$("#formTwo").submit(function() {
alert("Trying to submit to: formTwo");
return false;
});

$("#sbtBtn").click(function() {
if($("#retUser").val()) {      //check if #retUser has a value
$("#formOne").submit();
} else if ($("#fname").val() && $("#lname").val() && $("#email1").val()) {
$("#formTwo").submit();
}
});

what I can’t get is the “If there is NO value in any field return an alert”
thx

  • 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-17T14:52:47+00:00Added an answer on May 17, 2026 at 2:52 pm

    I think what you’re after is another else on the end, like this:

    $("#sbtBtn").click(function() {
      if($("#retUser").val()) {
        $("#formOne form").submit();
      } else if ($("#fname").val() && $("#lname").val() && $("#email1").val()) {
        $("#formTwo form").submit();
      } else {
        alert("Please fill in something");
      }
    });
    

    Also note the changed selectors, since the <form> elements are inside the <div> elements with the IDs.

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

Sidebar

Related Questions

I have previously constructed an array manually, e.g.: <?php $noupload = array('nick', 'cliff'); ?>
Nick Craver really helped me out alot with this code in this thread jQuery
I've had this problem before but was able to work around it until now,
I need a little help with an IRC bot I'm creating (very simple). <?php
Here's my code: <?php $sock = fsockopen(localhost, 6667); fwrite($sock, NICK PHP_thang\r\n); fwrite($sock, USER fikeh
So, I'm doing a project and now I have a question, so I would
I have a couple of problems with my container DIV. For one it is
I'm trying to have a dynamic textview based on the xml file..... Please help
Any help would be appreciated. I am trying to have SalesForce push out account
Help me translate following block of the Haskell code. The run function produces text

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.