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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:54:48+00:00 2026-06-14T11:54:48+00:00

I have a form which validates that an option is selected using a returned

  • 0

I have a form which validates that an option is selected using a returned boolean from a function:

<form  id="checkoutForm" action="https://www.paypal.com/cgi-bin/webscr" onsubmit="return validateForm()" method="post" name="paypal">

And I was submitting the form with this standard image button:

<input name="submit" type="image"  src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" value="Checkout">

However I’ve been updating and am using a CSS button instead so submit the form as so:

 <a href="javascript:void(0)" style="float:right;" class="shopbutton" onclick="document.forms['checkoutForm'].submit();">Checkout with PayPal</a>

I can just use the standard button like so:

<input name="submit" type="submit"  class="shopbutton" value="Checkout">

But this causes me some other small issues and I’d like to know how to ensure the form validates using the other method?

TIA

Edit: I should also mention that when using the <a href type button that the button is declared outside of the <form> tags.

  • 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-14T11:54:49+00:00Added an answer on June 14, 2026 at 11:54 am

    You are bypassing the onsubmit when directly submitting the form with javascript. This is one example why client-sided validation is bad.

    One solution to your problem would be to append your a link like this:

    <a href="javascript:void(0)" style="float:right;" class="shopbutton" onclick="validateForm()">Checkout with PayPal</a>
    

    And then just add some error count to the validation function, and submit within the function if no errors were found, like so:

    function validateForm() {
        var errors = 0;
        if(inputFieldHere.value.length<3) errors++;
        if(errors) return false; //Or display some error or something
        else document.forms["checkoutForm"].submit();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that validates using the jQuery plugin: Validation, v1.9.0. The validation
I have a view which validates data from a form which just has some
I have this form that validates the fields on submit through ajax (using Codeigniter's
I have a script which validates each stage of a form and adds a
I have a login form which sends 3 post values from username, password and
I have a form which contains among others: <form id=new_basic_ad class=new_basic_ad method=post enctype=multipart/form-data action=/basic_ads
I have a form that validates the information submitted within a form, method is
I have written the following ajax code which validates my form which is actually
I have a simple html login form which is validated with javascript before its
I have a jsp form validate.jsp which contains 2 text fields where user enters

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.