Re: Forms, Validation of matching fields

Macromedia Dreamweaver

Forms, Validation of matching fields


Art 11-14-2005, 5:29 PM

I have created a form and want to verify that the user has correctly enter there email address twice, once in the email field and once in the verify email field. As good as Dreamweaver MX 2004 is, the 'Behaviors' do not offer this 'OnSubmit' in the Validate dialog window. Is there an easy way to complete this task?

Re: Forms, Validation of matching fields


MHunt 02-26-2006, 9:57 AM
Wow, not much participation .. too bad..

Anyway, As far as validating an email address from Dreamweaver, I found that I rather write my own code..

Here's a link to validadting an email address

http://javascript.internet.com/forms/email-address-validation.html

As for comparing the email address you can do it by a simple comparision:

<SCRIPT LANGUAGE="JavaScript">

function checkEmail(form) {
email1 = form.email1.value;
email2 = form.email2.value;

if (email1 != email2) {
alert ("\nEmail addresses are different.")
return false;
}
else return true;
}

</script>

<form onSubmit="return checkEmail(this)">
<center>
<table border=0>
<tr>
<td>Email:</td><td><input type=text name=email1size=10></td>
</tr>
<tr>
<td>Confirm Email:</td><td><input type=text name=email2 size=10></td>
</tr>
<tr>
<td colspan=2 align=center><input type=submit value="Submit!"></td>
</tr>
</table>
</form>


Hope that helps

Re: Forms, Validation of matching fields


Chevy B 08-14-2007, 6:22 PM
Dude,

A quick solution is to create a form validation function that uses Regular Expressions to validate the format of the email address entered prior to submitting the form. Here is a little snipplet I built:


Email Validation Testing

//Author: Chevroll Bryan
//Email: chevrollbryan@yahoo.com
//Date of Creation: June 2004
//Description: This is a simple script that uses Regular Expression to validate email address from a form before it gets submitted.
function ValidateEmailAddress(txtField)
{
var str=txtField.value
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (!filter.test(str))
{
alert("Please input a valid email address!")
txtField.select();
txtField.focus();
return false;
}
else
{
alert('A valid email address was entered!');
return true;
}
}





Enter Email Address :
<br />



webhost4life.com

Powered by Community Server, by Telligent Systems