-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.cfm
More file actions
89 lines (75 loc) · 2.91 KB
/
example.cfm
File metadata and controls
89 lines (75 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!---
<fusedoc fuse="example.cfm" language="ColdFusion" specification="2.0">
<responsibilities>
I am an example of Validation.cfc form validation.
</responsibilities>
<properties>
<history
author="Ryan J. Heldt"
email="rheldt@ryanheldt.com"
date="2008-10-08"
type="modify" role="architect"
comments="" />
<property name="copyright" value="Copyright 2008 Ryan J. Heldt. All rights reserved." />
</properties>
</fusedoc>
--->
<cfparam name="form.Name" default="" />
<cfparam name="form.Email" default="" />
<cfparam name="form.WebSite" default="" />
<cfparam name="form.Age" default="" />
<cfparam name="form.Password" default="" />
<cfparam name="form.Password2" default="" />
<html>
<head>
<title>Validation.cfc Example</title>
<style>
.redtext {
color: red;
}
</style>
</head>
<body>
<h1>Validation.cfc Example</h1>
<!--- Since We're Doing a Postback --->
<cfif isDefined("form.fieldnames")>
<cfscript>
objValidation = createObject("component","com.Validation").init();
objValidation.setFields(form);
objValidation.validate();
</cfscript>
<cfif objValidation.getErrorCount() is 0>
<h2>No errors!</h2>
<cfelse>
<h2>There were <cfoutput>#objValidation.getErrorCount()#</cfoutput> errors in your submission:</h2>
<ul>
<cfloop collection="#variables.objValidation.getMessages()#" item="rr">
<li><cfoutput>#variables.objValidation.getMessage(rr)#"</cfoutput></li>
</cfloop>
</ul>
</cfif>
</cfif>
<cfoutput>
<form action="example.cfm" method="post">
<p>Name: <span class="redtext">*</span><br />
<input type="text" name="Name" value="#form.Name#" /></p>
<p>E-mail Address: <span class="redtext">*</span><br />
<input type="text" name="Email" value="#form.Email#" /></p>
<p>Web Site:<br />
<input type="text" name="WebSite" value="#form.WebSite#" /></p>
<p>Your Age:<br />
<input type="text" name="Age" value="#form.Age#" /></p>
<p>Password: <span class="redtext">*</span><br />
<input type="Password" name="Password" value="#form.Password#" /></p>
<p>Confirm Password: <span class="redtext">*</span><br />
<input type="Password" name="Password2" value="#form.Password2#" /></p>
<input name="validate_require" type="hidden" value="Name|'Name' is a required field.;Email|'E-mail Address' is a required field.;Password|'Password' is a required field.;Password2|'Confirm Password' is a required field." />
<input name="validate_password" type="hidden" value="Password|Password2|'Password' and 'Confirm Password' must both match." />
<input name="validate_email" type="hidden" value="Email|'E-mail Address' must be a valid e-mail address." />
<input name="validate_url" type="hidden" value="WebSite|'Web Site' must be a valid web site address." />
<input name="validate_numeric" type="hidden" value="Age|'Age' must be a number." />
<input type="submit" value="Submit" />
</form>
</cfoutput>
</body>
</html>