Validation

P

Paul Beckett

I am having problems getting validation to work on my form (see below). The
form gets posted regardless of whether the HospitalNumber field is
populated!

Can anyone help me?

Paul Beckett

<%@ Page Language="VB" debug="true"%>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls"
Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,c
ulture=neutral" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

</script>
<MM:Insert
runat="server"
CommandText='<%# "INSERT INTO dbo.PatientDetails (FirstName, Surname, DOB,
HospitalNumber, Policy, PolicyNumber, Address1, Address2, Address3,
Address4, Postcode, Telephone1, Telephone2, GPID) VALUES (?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?)" %>'
ConnectionString='<%#
System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING
_Private") %>'
DatabaseType='<%#
System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABA
SETYPE_Private") %>'
Expression='<%# Request.Form("MM_insert") = "form1" %>'
CreateDataSet="false"
SuccessURL=' said:
<Parameters>
<Parameter Name="@FirstName" Value='<%# IIf((Request.Form("FirstName") <>
Nothing), Request.Form("FirstName"), "") %>' Type="VarChar" />
<Parameter Name="@Surname" Value='<%# IIf((Request.Form("Surname") <>
Nothing), Request.Form("Surname"), "") %>' Type="VarChar" />
<Parameter Name="@DOB" Value='<%# IIf((Request.Form("DOB") <> Nothing),
Request.Form("DOB"), "") %>' Type="VarChar" />
<Parameter Name="@HospitalNumber" Value='<%#
IIf((Request.Form("HospitalNumber") <> Nothing),
Request.Form("HospitalNumber"), "") %>' Type="VarChar" />
<Parameter Name="@Policy" Value='<%# IIf((Request.Form("Policy") <>
Nothing), Request.Form("Policy"), "") %>' Type="VarChar" />
<Parameter Name="@PolicyNumber" Value='<%#
IIf((Request.Form("PolicyNumber") <> Nothing), Request.Form("PolicyNumber"),
"") %>' Type="VarChar" />
<Parameter Name="@Address1" Value='<%# IIf((Request.Form("Address1") <>
Nothing), Request.Form("Address1"), "") %>' Type="VarChar" />
<Parameter Name="@Address2" Value='<%# IIf((Request.Form("Address2") <>
Nothing), Request.Form("Address2"), "") %>' Type="VarChar" />
<Parameter Name="@Address3" Value='<%# IIf((Request.Form("Address3") <>
Nothing), Request.Form("Address3"), "") %>' Type="VarChar" />
<Parameter Name="@Address4" Value='<%# IIf((Request.Form("Address4") <>
Nothing), Request.Form("Address4"), "") %>' Type="VarChar" />
<Parameter Name="@Postcode" Value='<%# IIf((Request.Form("Postcode") <>
Nothing), Request.Form("Postcode"), "") %>' Type="VarChar" />
<Parameter Name="@Telephone1" Value='<%# IIf((Request.Form("Telephone1")
<> Nothing), Request.Form("Telephone1"), "") %>' Type="VarChar" />
<Parameter Name="@Telephone2" Value='<%# IIf((Request.Form("Telephone2")
<> Nothing), Request.Form("Telephone2"), "") %>' Type="VarChar" />
<Parameter Name="@GPID" Value='<%# IIf((Request.Form("GPID") <> Nothing),
Request.Form("GPID"), "") %>' Type="Integer" />
</Parameters>
</MM:Insert>

<MM:DataSet
id="dsGP"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%#
System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING
_Private") %>'
DatabaseType='<%#
System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABA
SETYPE_Private") %>'
CommandText=' said:
</MM:DataSet>
<MM:pageBind runat="server" PostBackBind="true" />


<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
<link href="layout.css" type="text/css" rel="stylesheet" />
<style type="text/css">
<!--
..style1 {font-size: 12px}
..style2 {
font-size: 11px;
color: #FF0000;
}
..style3 {color: #FF0000}
..style4 {font-size: 9px}
-->
</style>
</head>
<body>
<div class="content">
<h1 align="center">Private Practice Database</h1>
</div>
<div class="content" align="center">

<p>&nbsp;</p>

<form method="post" name="form1" runat="server">
<table align="center">
<tr valign="baseline">
<td width="164" align="right" nowrap>&nbsp;</td>
<td width="234">
<span class="style3">**</span>Required field</td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><span
class="style3">**</span>FirstName:</td>
<td>
<asp:textbox BackColor="#FFFFCC" Columns="32" id="FirstName"
runat="server" TextMode="SingleLine" /></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><span class="style3">**</span>Surname:</td>
<td>
<asp:textbox BackColor="#FFFFCC" Columns="32" id="Surname"
runat="server" TextMode="SingleLine" /></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">DOB <span
class="style4">(dd/mm/yyyy)</span>:</td>
<td>
<asp:textbox BackColor="#FFFFCC" id="DOB" TextMode="SingleLine"
Columns="32" runat="server" /></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><span class="style3">**</span>Hospital
Number:</td>
<td>
<asp:textbox BackColor="#FFFFCC" id="HospitalNumber"
TextMode="SingleLine" Columns="32" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator"
ControlToValidate="HospitalNumber" ErrorMessage="Required" Display="Static"
runat="server"></asp:RequiredFieldValidator></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Policy:</td>
<td>
<asp:textbox BackColor="#FFFFCC" id="Policy" TextMode="SingleLine"
Columns="32" runat="server" /></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Policy Number:</td>
<td>
<asp:textbox BackColor="#FFFFCC" id="PolicyNumber"
TextMode="SingleLine" Columns="32" runat="server" /></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Address1:</td>
<td>
<asp:textbox BackColor="#FFFFCC" id="Address1"
TextMode="SingleLine" Columns="32" runat="server" /></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Address2:</td>
<td>
<asp:textbox BackColor="#FFFFCC" id="Address2"
TextMode="SingleLine" Columns="32" runat="server" /></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Address3:</td>
<td>
<asp:textbox BackColor="#FFFFCC" id="Address3"
TextMode="SingleLine" Columns="32" runat="server" /></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Address4:</td>
<td>
<asp:textbox BackColor="#FFFFCC" id="Address4"
TextMode="SingleLine" Columns="32" runat="server" /></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Postcode:</td>
<td>
<asp:textbox BackColor="#FFFFCC" id="Postcode"
TextMode="SingleLine" Columns="32" runat="server" /></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Telephone 1:</td>
<td>
<asp:textbox BackColor="#FFFFCC" id="Telephone1"
TextMode="SingleLine" Columns="32" runat="server" /></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Telephone 2:</td>
<td>
<asp:textbox BackColor="#FFFFCC" id="Telephone2"
TextMode="SingleLine" Columns="32" runat="server" /></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><span class="style3">**</span>GP:</td>
<td>
<% GPID.SelectedIndex =
GPID.Items.IndexOf(GPID.Items.FindByValue("")) %>
<asp:dropdownlist BackColor="#FFFFCC"
DataSource="<%# dsGP.DefaultView %>"
DataTextField="GP3"
DataValueField="GP_ID" id="GPID"
runat="server"> </asp:dropdownlist>
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td><input name="button1" type="submit" id="button1" value="Insert
record"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p>&nbsp;</p>
</div>
<div align="left">
<div class="content">
<p>
</p>
<p align="center">
<a title="" href="">:: &nbsp;2004 Paul Beckett</a> &nbsp;::
</p>
</div>
</div>
<div id="navAlpha">
<h2>Links
</h2>
<p>
<a title="" href="">List All Patients</a>
<br />
<a title="" href="">List All Episodes</a>
<br />
<a title="" href="">List All GPs</a>
<br />
<a title="" href="">List All Procedures</a>
<br />
<a title="" href="">Fake Link One</a>
<br />
<a title="" href="">Fake Link Two</a>
<br />
<a title="" href="">Fake Link Three</a>
<br />
<a title="" href="">Fake Link Four</a>
<br />
<a title="" href="">Fake Link Five</a>
<br />
</p>
</div>
<div id="navBeta">
<h2 align="center"><img src="Images/stethoscope-fade.jpg"
width="120" height="120" align="absmiddle" /> </h2>
<h2 align="left"><br />
<span class="style1">From here you can add a new patient to your
database.</span></h2>
<h2 align="left">&nbsp;</h2>
<h2 align="left"><span class="style1">Fields marked with <span
class="style3">**</span> are required.</span></h2>
</div>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top