logo.gif

The Email Form Validator JavaScript

The sample we are using is referring to a Bravenet E-mail Form. That is what we use on this site. If you use a different e-mail form processing service, you'll have to change the form tag. Thanks to Bravenet Web Services for providing this JavaScript. This is for ADVANCED CODERS ONLY PLEASE.

A Validation Script ensures your forms are filled out correctly.

With Javascript, you can require your visitors to fill in areas of the form. Try the form on the right. It doesn't send mail anywhere, so try it all you like. It requires you to fill in name and email address.
What 's Your Name?

Where are you from?

E-mail Address?

Comments and Questions?




Here is the copy/paste code for validating your email form.
You'll need to edit your existing form to make it work.

This code goes between the <HEAD> and the </HEAD> tags in your page:


<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>

And this RED code must go in your existing form tag:


<FORM onSubmit="return checkData()" NAME="Bravenet" action="http://www.bravenet.com/emailfwd/senddata.asp" method="POST">




~~~~~ Back to "Adding Email Forms" ~~~~~