Get Your Free Bravenet Account Here

Bravenet Form Validation Tutorial

B elow we shall show you how to add the Bravenet form validator to your Bravenet forms so you will not receive your orders with missing pertinent information. The below is the default form validator which the Bravenet support staff sent to us to validate our forms. You can also see this validator on their page if you follow the below link.
Email Form Validator ]

The below script gets pasted in between your <HEAD> and </HEAD> tags in your document.

<HEAD>

<!--------------- Start Bravenet Form Validator Script --------------->
<SCRIPT>
<!--
// E-mail Form - Validator
// Bravenet Web Services - www.bravenet.com
function checkData() {
var correct = true
if (document.Bravenet.name.value == "") {correct = false; alert("Please enter your name!")}
if (document.Bravenet.replyemail.value == "") {correct = false; alert("Please enter your e-mail address.")}
/*
You can add more variables above.
The name after the word Bravenet has to match the name in the form below.
*/
if (correct){alert("Thank you for taking your time to fill out this form.")}
return correct
}
//-->
</SCRIPT>
<!--------------- End Bravenet Form Validator Script --------------->

</HEAD>

T he above script is for all intensive purposes, self explanitory. We will elaborate on all the different reconfigurations that can be made within the script and your form(s).

F or each required field you have in your form you need to add the below line of script just above the /* in the validator. You also need to change the name of each field and message in the validator to match with the field name in your form. Remember, "Character and Case" sensitive!

if (document.Bravenet.replyemail.value == "") {correct = false; alert("Please enter your e-mail address.")}

E ach field within your form has a specific name. for example replyemail. This has to Match perfectly within your validator and form.

Form Validator=replyemail
Form=replyemail       Not Replyemail.

S o what you see in the above validator script you will also see in the form itself

Your E-Mail Address
<BR;><INPUT TYPE=TEXT NAME=replyemail SIZE=40 value="">

W ithin the validator the below is where you add you message if the field is left blank.

false; alert("Please enter your e-mail address.")}
This is where you add your message if the field would not be filled in. This is NOT case sensitive!

T he below section of the validator is where the message is if your visitor fills out the form correctly. If you do not like the default message, you can change this also. This is the only place you would change this. There is no configuration within the form itself for this.

*/
if (correct){alert("Thank you for taking your time to fill out this form.")}
return correct

B y now you are probably curious as to what the value="" means. If you do not want to add any message within the field (box) itself (such as "Enter Your Email Address") just leave it as is and do not concern yourself with it. If you do want to add something into the field, then you need to make two reconfigurations. One within the validator and the other within the form itself. Below is how it would look within your form.

Your E-Mail Address

Below Is Within Email Validator

if (document.Bravenet.replyemail.value == "Enter Your Email Address") {correct = false; alert("Please enter your e-mail address.")}

Below Is Within Form Itself

<p>Your E-Mail Address
<BR><INPUT TYPE=TEXT NAME=replyemail SIZE=40 value="Enter Your Email Address">

Yes it is Character & Case Sensitive! and must match!

W hat this does is to tell the validator that there are words within the field and are not the required answer so even with these words in the field, if the person tries to send the form, they will get the pop up telling them to submit the proper information.

A s usual, there are always exceptions to every rule. If you notice on the textarea box script below, there is not a value="" included within the form script and there should not be one. This section you only need to add the validation code itself into the validation script and not into the form itself. If you want to add words within the textarea field you can or not. It will not change the validation.

<p>Additional Comments
<BR><TEXTAREA WRAP=VIRTUAL NAME="additionalcomments" COLS=40 ROWS=5>You Can Add Anything You Want Here Since There Is No value="" Set Within The textarea box. </TEXTAREA>

Additional Comments

O n the working form, you do realize that if after your visitors fill out the form and decide to clear it, it will go back to the default of either nothing within the fields or the values you have set.

A nd this below code replaces the form tag you now have. The red is added into the form, not the validator. To see this better, follow the below link for
"Complete Form And Validator. You can notice it at the beginning of the email form itself.

<FORM onSubmit="return checkData()" name="Bravenet"
action="http://pubXX.bravenet.com/emailfwd/senddata.php" method="POST">

I f this is still slightly confusing, follow the below link and we have a complete validator and form set up with all the configurations.
Complete Form And Validator ]
Back To Form Validation ]

Copyright © Consigliere Ltd., All Rights Reserved. 2001-