forked from cfjedimaster/ColdFusion-Blog-Aggregator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact.cfm
64 lines (54 loc) · 1.78 KB
/
contact.cfm
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
<!---
Name : contact.cfm
Author : Raymond Camden
Created : July 29, 2007
Last Updated : July 29, 2007
History :
Purpose : The contact form.
--->
<cfparam name="form.dname" default="Your Name">
<cfparam name="form.demail" default="Your Email">
<cfparam name="form.comments" default="">
<script>
$(document).ready(function() {
$("#contactForm").submit(
function(e) {
var name = $("#dname").val()
var email = $("#demail").val()
var comments = $("#comments").val()
var error = "";
if(name == '' || name == 'Your Name') error+="Please include your name.\n";
if(email == '' || email == 'Your Email') error+="Please include your email address.\n";
if(comments == '') error+="Please include your comments.\n";
if(error != '') { alert(error); e.preventDefault(); }
else {
$.post("sendcontact.cfm",{dname:name,demail:email,comments:comments},formDone);
e.preventDefault()
}
})
})
clearDefaultName = function() {
if($("#dname").val() == 'Your Name') $("#dname").val('')
}
clearDefaultEmail = function() {
if($("#demail").val() == 'Your Email') $("#demail").val('')
}
formDone = function(resp) {
alert('Thank you for your comments!');
$("#contact").dialog("close")
}
</script>
<cfoutput>
<form id="contactForm" action="contact.cfm" method="post">
<p style="text-align:left;">
<label>Name</label>
<input id="dname" name="dname" value="#form.dname#" type="text" size="30" onclick="clearDefaultName()" />
<label>Email</label>
<input id="demail" name="demail" value="#form.demail#" type="text" size="30" onclick="clearDefaultEmail()" />
<label>Your Comments</label>
<textarea rows="5" cols="5" name="comments" id="comments">#form.comments#</textarea>
<br />
<input class="button" type="submit" value="Send Comments" />
</p>
</form>
</cfoutput>