www.webdeveloper.com
Results 1 to 4 of 4

Thread: Required Fields With PayPal button

  1. #1
    Join Date
    Sep 2010
    Posts
    36

    Required Fields With PayPal button

    Hi there,

    I am using the following function to check for a required field:

    Code:
    function verify() {
    var themessage = "You are required to complete the following fields: ";
    if (document.order.tandc.value=="") {
    themessage = themessage + " - Terms & Conditions";
    }
    //alert if fields are empty and cancel form submit
    if (themessage == "You are required to complete the following fields: ") {
    document.order.action=insertstandard.php;
    }
    else {
    alert(themessage);
    return false;
       }
    }
    The code is checking for the required field, and displays the alert box however when the user clicks ok, the form is still processed!

    Any help with this much appreciated.

    Kind regards, Mike

  2. #2
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    Wherever you are calling the function, remember to put "return " in front of the function name.

    ^_^

  3. #3
    Join Date
    Sep 2010
    Posts
    36
    Haha, something so small messes it all up!

    Thanks very much!

    Kind regards, Mike

  4. #4
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    I've made that same mistake several times, even recently. It happens. Glad you got it working.

    ^_^

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles