har problemer med emailvalidering via javascript
jeg har følgende kode:<html>
<head>
<title>Untitled</title>
</head>
<body>
<script language="JavaScript">
function validateMail(email) {
if (email != '') {
// Rules for the email regular expression:
// The start of the email must have at least one character
// before the @ sign
// There may be either a . or a -, but not together before the @ sign
// There must be an @ sign
// At least once character must follow the @ sign
// There may be either a . or a -, but not together in the address
// The address must end with a and either 2 or 6 characters
three = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/;
if (!three.test(email)) {
alert('Kunne ikke verificere den indtaste e-mailadresse, prøv venligst igen');
event.returnValue = false;
}
}
else
event.returnValue = false;
}
</script>
<%
'Skaber forbindelse til databasen og henter indholdet af den
' Databaseforbindelse - husk at angive sti til din database
if request.form("txtEmail") <> ""then
DSN = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="& Server.MapPath("Db/Attif.mdb")'"C:\Inetpub\wwwroot\attif\Db\Attif.mdb" '
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open DSN
strSQL = "Insert into Nyhedsbrev (Email) values('"& Request.Form("txtEmail") & "')"
Conn.Close
Set Conn = Nothing
end if
%>
<form action="tester.asp" method="post">
Email:<input type="Text" name="txtEmail" />
<input type="submit" value="Opret" onclick="validateMail(this.value)">
</form>
</body>
</html>
Lige meget hvad jeg skriver i mit indputfelt skriver den at emailadressen ikke er rigtig, nogen der kan hjælpe?
