ABVFP Check Box

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • greyhame
    Sergeant

    • Jun 2006
    • 36

    ABVFP Check Box

    Can someone tell me how I can validate whether a checkbox is checked when a form is submitted. I have a form for users to sign up for a newsletter. Users must agree to a statement in the form by checking the box. I would like to be able to reject the form if it is unchecked. Thanks.
    No matter how fast you are going, there is always someone trying to pass.
  • navaldesign
    General & Forum Moderator

    • Oct 2005
    • 12080

    #2
    Re: ABVFP Check Box

    This is usually done using Javascript, before the form info is even submitted. Here is my preferred method. I use it because it will not get in conflict with BV's own form fields validation, so you can use both in the same form.

    We will suppose that you are using a standard BV form, named Form1. If the name is different, change the part in RED to be the same as the form name. We will also suppose that the checkbox is named "agree". If not, change the part in BLUE to be the same as the checkbox name:

    Step 1. Paste the following code in the "Between head Tag" of your page html:

    <script>
    //"Accept terms" form submission- By Dynamic Drive
    //For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
    //This credit MUST stay intact for use
    var checkobj
    function agreesubmit(el){
    checkobj=el
    if (document.all||document.getElementById){
    for (i=0;i<checkobj.form.length;i++){ //hunt down submit button
    var tempobj=checkobj.form.elements[i]
    if(tempobj.type.toLowerCase()=="submit")
    tempobj.disabled=!checkobj.checked
    }
    }
    }
    function defaultagree(el){
    if (!document.all&&!document.getElementById){
    if (window.checkobj&&checkobj.checked)
    return true
    else{
    alert("Please read/accept terms to submit form")
    return false
    }
    }
    }
    </script>
    Step 2. Right Click on the form, select HTML, and paste the following code in the AFTER TAG of the form html:

    <script>
    //change two names below to your form's names
    document.forms.Form1.agree.checked=false
    </script>
    Step 3. Right Click on the checkbox, select HTML, and paste the following code in the INSIDE TAG of the checkbox HTML:

    onClick="agreesubmit(this)"
    Step 4. Right click on your Submit button, select HTML, and paste the following code in the Inside Tag of the Submit button HTML:

    disabled
    That's all.

    This script is presented at http://www.dynamicdrive.com/dynamici...acceptterm.htm

    I just show here how to use it with a BV form.

    To see it working, visit http://www.dbtechnosystems.com/Tips/Agree_to_Terms.html
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

    Comment

    • greyhame
      Sergeant

      • Jun 2006
      • 36

      #3
      Re: ABVFP Check Box

      Greatly appreciated! This disables the submit button until the agree box is checked.
      No matter how fast you are going, there is always someone trying to pass.

      Comment

      Working...
      X