<html><head>
<%PageTitle="Display and validation"%>
<!-- #include virtual="/include/head.asp"-->
<a href="/include/code.asp?<%=Request.ServerVariables("url")%>" target=code><b>Show Code</b></a><br>
<div>This is a working page of a sample application. Please try submitting different data. See how errors are handled.</div>
<%on error resume next
Set User=server.CreateObject("DB3NF.Item")
set objSchema=User.SchemaObj 'Display functions from included display.asp need it to work
User.Class="user"

User.ID=2 'here we connect to existing item

if Request.Form.Count>1 then
	user.Form=Request.Form

	'********************* custom handling of email property: ************************
	if User("email").Valid then 'default handling didn't find any errors
		if instr(User("email"), "@")<2 or instr(User("email"), ".")<4  then _
			User("email").ErrorMessage="Email is invalid"
	end if
	'******************** end of custom handling of email property *******************

	if User.Validate then
		User.SetInfo
		Msg="Info saved"
	end if
end if


%>
<p class=InfoMsg><%=msg%></p>
<form method=post id=form1 name=form1>
<table class=PropertyTable width=550 cellspacing=0>
<%
for each Prop in User.Properties
	'**********************    custom display of comments  ***************************
	if Prop.Name = "comments" then
		%>
		<tr><td colspan=2 class=PropertyTableTD>
		<center>This is custom display of comments:</center>
		<br><br><b><%=IIF(Prop>"", Prop, "Comments not available")%>
		</td></tr>
		<%
	'*******************  end of custom display of comments  *************************
	else
		Display Prop, Prop.Name="username" 'we don't allow to edit username
	end if
next

%>
<td colspan=2 align=CENTER class=PropertyTableSubmit>
	<input type=submit value=<%=IIF(User.ID, "Edit", "Submit")%> id=submit1 name=submit1>
</td>
</table>

</form>
<%
if err then Response.Write "<p><b>Application error</b></p>"
%>
<!-- #include virtual="/include/footer.asp"-->