Hvorfor virker validering af e-mail formen ikke
HejEr der nogen der kan se hvad der ikke passer i dette script.
Mener selv at det hele skulle være i orden.
<script language="JavaScript">
<!--
function valider() {
var errorMsg = "";
if (document.newtag.email.value.match(/^[a-z0-9_\.]+@[a-z0-9_\.]+\.\w{2,4}$/i)) {
errorMsg += "\n\tEmail \t\t- Angiv en rigtig emailadd.";
}
//Fejlbeskrivelse
if ((errorMsg != "")){
msg = "_________________________________________________\n\n";
msg += "Din email er ikke blevet tilføjet \n";
msg += "_________________________________________________\n\n";
msg += "\n";
errorMsg += alert(msg + errorMsg);
return false;
}
if (errorMsg == 0) {
document.newtag.submitbutton.disabled = true;
}
return true;
}
// -->
</script>
</body>
<%
email = Trim(Request.Form("email"))
If Len(email) = 0 Then
%>
<br>
<BASEFONT FACE="verdana">
<TABLE BORDER="0" WIDTH="100%"><TR>
<div align="center">
<%
response.write "<font size=2 face=Verdana, Arial, Helvetica, sans-serif><b>Indtaste din email adresse</b></font>"
%>
<form method="POST" action="nybruger.asp" NAME="newtag" onsubmit="return valider()">
Emailadresse: <input type="text" name="email" size="20" value="<% =email %>">
<br><br>
<Input CHECKED type="radio" name="valg" value="1">
Tilmeld
<Input type="radio" name="valg" value="2">
Afmeld
<br><br>
<input type="submit" value="Send" name="submitbutton">
</form>
</div>
</TR>
</table>
<%
Else
if Request.Form("valg") = "1" then
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("mail.mdb") & ";UID=admin;PWD=;"
Set rs = Server.CreateObject("ADODB.RecordSet")
strSQL = "SELECT * FROM mail WHERE email='" & email & "'"
rs.Open strSQL, Conn, 1, 3
if rs.EOF then
rs.AddNew
rs("email") = email
rs.Update
rs.Close
Set rs = Nothing
Conn.Close
set Conn = Nothing
%>
<TABLE BORDER="0" WIDTH="100%">
<TR><div align="center"><br>
<% response.write "<font size=2 face=Verdana, Arial, Helvetica, sans-serif><b>Du er nu optaget på mailinglisten</b></font>" %>
</div>
</TR>
</table>