PDA

View Full Version : Checkbox problem on paypal form



Aliens Anonymous
07-30-2007, 12:03 AM
Hi Dudes
having a bit of a mare making checkbox's required. as bv has not got the option on the builder i take it, it requires javascript. when you publish a bv page it makes the script for you for text, combos, etc boxs in the form of a script like this.



if (theForm.Editbox8.value == "")
{
alert("Please enter a value for the \"Email\" field.");
theForm.Editbox8.focus();
return false;
}


this being, i edited the html page and added the script



if (theForm.Checkbox1.value == "")
{
alert("You have not checked the \"item name\" field.");
theForm.Checkbox1.focus();
return false;
}


But still no go, in the first checkbox i have a value of phpbb Insulation this so paypal know what it is. but i found the if i changed value =="") to value =="phpbb Insulation") the warning would work but because you can't wright text in to a checkbox i could not fill the field so that did not work.
My question is there a way to have the checkbox be required if so were am i going wrong. if no then DAMN. and thanks anyway.

One of the forms is Here (http://angies-cyberscripts.org/test_forms/phpbb_order.html)

navaldesign
07-30-2007, 07:04 AM
Well, the logic is correct. But, since, as you have crrectly stated, the checkbox has already a value, you need to check if it is checked or not, and this is done by defining and examining (with Javascript) the value of the "Form.checkbox.checked" variable.

I will assume here that no other fields are required, so the function i will show you is a standalone, only for this checkbox. If more fields are required, or your form has also other types of validation, you must modify the script.


I am assuming that you are using BV, so the form, if it is the first form in the page, will have the default name "Form1" and let's also suppose that the checkbox has the name "check".

Here is what you need to do:

1. Paste this function code in the Page Between Head:

<script language="JavaScript" type="text/javascript">
<!--
function ValidateForm1(theForm)
{
if (theForm.check.checked==false)
{
alert("Please check the \"Checkbox\" field.");
return false;
}
return true;
}
//-->
</script>



2. Paste this script in the Form html INSIDE TAG:

onsubmit="return ValidateForm1(this)

3. Paste his code in the Form html AFTER TAG:

<script>
//change two names below to your form's names
document.forms.Form1.check.checked=false
</script>

Check out the validation at http://www.dbtechnosystems.com/Tips/required_checkbox.html

As you see, it uses part of the same script that you have used for the "Agree to Terms" checkbox.

One question: Form Insulation ? !!!? you mean Forum Installation ?

Aliens Anonymous
07-30-2007, 10:14 PM
Well you have come up trumps agian had a bit of touble because of other validated field had a lot of trouble with the tag item you gave checkbox kept flying off the page, but i found that if i edited the html page it's self and adding part of the head script you gave i found it worked as i wanted


if (theForm.item_name.checked==false)
{
alert("You have not checked the \"Item\" Box.");
return false;
}
if (theForm.amount.checked==false)
{
alert("You have not checked the \"Amount\" Box.");
return false;
}

So thanks to you i can now continue Thanks alot for your help.


One question: Form Insulation ? !!!? you mean Forum Installation ? Yes your right there got so rapped up in the checkboxs that i had not noticed

navaldesign
07-30-2007, 10:27 PM
This is the reason that i usualy do NOT use the BlueVoda validation. I prefer a php preview / validation page where i can perform ANY type of validation, and from there create my PayPal button and send the visitor to payment.
When i need Javascript validation, i usually create my code myself and add it in the page