Question : check email address match in form (javascript validation)

Hi,

Does anyone have any sample code to validate that two email entries in a form match using javascript?

thanks,

Answer : check email address match in form (javascript validation)

I added a 'return false' to the check.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
<html>
<head>
<script type="text/javascript">
function chkstr()
{
var Eml1=document.getElementById("eml1").value;
var Eml2=document.getElementById("eml2").value;

if(Eml1 != Eml2) {
	alert("Email addresses don't match.");
	return false;
	}
}
</script>
</head>
<body>
<h1>js-strcmp.html</h1>
<form action="#" method="get" onsubmit="return chkstr();">
<input type="text" name="eml1" id="eml1" value="Email 1" /><br />
<input type="text" name="eml2" id="eml2" value="Email 2" /><br />
<input type="submit" value="Submit" />
</form>

</body>
</html>
Random Solutions  
 
programming4us programming4us