Hvis du vil sikre dig at brugeren skal indtaste en overskrift og en kommentar (det hedder felterne i koden indlaeg.asp) så skal det laves i javascript - jeg har ændret indlaeg.asp til nedenstående som kan bruges som det er:
<%
' --------------------------------------------------------------------------------
' Dette eksempel er skrevet af Dennis Knappe
' Og omskrevet af Lars Hansen/Ole H. hansen - logiweb.dk
' Eksemplet kan downloades fra
http://www.activeserverpages.dk, og er freeware
' --------------------------------------------------------------------------------
Const adOpenKeyset = 1
Const adLockOptimistic = 3
strMode = Request.QueryString("mode")
tempConn = "PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("news.mdb") & ";UID=admin;PWD=;"
If Request.Form("Gem") <> "" Then
strNavn = Trim(Request.Form("Overskrift"))
strKommentar = Trim(Request.Form("Kommentar"))
Set rs = Server.CreateObject("ADODB.RecordSet")
strSQL = "SELECT * FROM news WHERE (ID = 0)"
rs.Open strSQL, tempConn, adOpenKeyset, adLockOptimistic
If (rs.BOF Or rs.EOF) Then
rs.AddNew
rs("Overskrift") = strNavn
rs("Kommentar") = strKommentar
rs("Dato") =Date()
rs.Update
End If
rs.Close
Set rs = Nothing
End If
%>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title></title>
<style type="text/css">
<!--
.update { font-family: Verdana; font-size: 8 pt; font-style: italic; color: #728999 }
.text { font-family: Verdana, Arial; font-size: 10px; color: #3C4248; font-weight:
bold }
.close { font-family: Verdana, Arial; font-size: 11px; color: #FFCC66; font-weight:
bold }
BODY {
font-family: Verdana;
font-size: 10px;
font-style: normal;
color: #ffffff;
}
A:LINK {
font-family: Verdana,Arial;
font-size: 10px;
font-style: normal;
text-decoration : underline;
color: #ffffff;}
A:VISITED {
font-family: Verdana,Arial;
font-size: 10px;
font-style: normal;
text-decoration : none;
color: #FF7318;
}
A:HOVER {
font-family: Verdana,Arial;
font-size: 10px;
font-style: normal;
text-decoration : none;
color: #3C4248;
}
TD {
font-family: Verdana;
font-size: 10px;
font-weight: normal;
font-style: normal;
color: #ffffff;
}
-->
</style>
<base target="_self">
</head>
<body background="images/bg.gif" bgcolor="#525A63" bgproperties="fixed" topmargin="5" leftmargin="1" style="SCROLLBAR-HIGHLIGHT-COLOR: #525A63; scrollbar-base-color:#3C4248; SCROLLBAR-SHADOW-COLOR: #525A63; COLOR: #ffffff; SCROLLBAR-3DLIGHT-COLOR: #3C4248; SCROLLBAR-ARROW-COLOR: #525A63; SCROLLBAR-TRACK-COLOR: #3C4248; SCROLLBAR-DARKSHADOW-COLOR: #3C4248;">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="252">
<tr>
<td align="center" width="100%"><form
action="indlaeg.asp" method="POST" onsubmit='return FormValidate(this)'>
<div align="left"><table border="0" cellpadding="0"
cellspacing="0" width="248">
<tr>
<td colspan="2" width="246"> Indtast venligst en
"tag" i følgende felter:<br>
</td>
</tr>
<tr>
<td align="left" width="39"><p align="left"><b>Navn :</b></p>
</td>
<td width="205"><input type="text" size="38"
name="Overskrift" style="background-color: #525A63; color: #FFFFFF; font-family: Verdana; font-size: 10 px; border: 1 solid #3C4248"></td>
</tr>
<tr>
<td valign="top" align="left" width="39"><p align="left"><b>Tekst :</b></p>
</td>
<td width="205"><textarea name="Kommentar" rows="5"
cols="37" style="font-family: Verdana; font-size: 10 px; background-color: #525A63; color: #FFFFFF; border: 1 solid #3C4248"></textarea></td>
</tr>
<tr>
<td width="39"><br>
</td>
<td width="205">
<input type="submit" name="Gem" value="Gem" style="background-color: #525A63; color: #FFFFFF; font-family: Verdana; font-size: 10 px; border: 1 solid #3C4248">
<input
type="button" name="Annuller"
value="Annuller"
onclick="java script:history.back();" style="font-family: Verdana; font-size: 10 px; background-color: #525A63; color: #FFFFFF; border: 1 solid #3C4248"></td>
</tr>
</table>
</div>
</form>
</td>
</tr>
</table>
</center>
</div>
<div align="center">
<center>
<table border="0" width="252" cellspacing="0" cellpadding="0">
<tr>
<td width="441">
</td>
</tr>
</table>
</center>
</div>
<script language="JavaScript"><!--
function FormValidatorEditVare(theForm)
{
if (theForm.Overskrift.value == "")
{
alert("Varen skal angives en overskrift.");
theForm.Overskrift.focus();
return (false);
}
if (theForm.Kommentar.value == "")
{
alert("Der skal indtastes en kemmentar.");
theForm.Kommentar.focus();
return (false);
}
return (true);
}
//--></script>
</body>
</html>