| VDaemon v3 Samples | |
This sample demonstrates new experimental error messanging mode of VDaemon v3.x.
VDaemon v3.x can refresh error messages (labels and summary) after visitor clicks submit button ("onsubmit" mode - old one) or after visitor changes some information on the form ("onchange" mode - new one). Currently "onchange" validation mode refreshes error messages on "onblur" event rather than "onchange". This mode is working only for javascript validation (it uses javasript events).
Use "validationmode" attribute of <form> tag to choose the mode. It can take values "onsubmit" or "onchange". Default is "onsubmit". In this example "onchange" mode is turned on in the following string:
<form method="POST" id="QContact" runat="vdaemon" action="qcontact_p.php" disablebuttons="all" validationmode="onchange">
This mode is experimental and can be removed in the future. I am not sure whether it even needed to someone. I welcome your opinions/suggestions about this mode on the forum.
Sample contains a typical quick contact/feedback form which allows user to send questions to a support staff. Actually no mail will be sent from this sample form. To make it working you need uncomment 'mail' function in the action page (qcontact_p.php).
<?php include('vdaemon.php'); ?>
<html>
<head>
<title>Quick Contact Form Sample</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="samples.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>Quick Contact Form Sample</h1>
<form method="POST" id="QContact" runat="vdaemon" action="qcontact_p.php" disablebuttons="all" validationmode="onchange">
<table cellpadding="2" cellspacing="0" border="0">
<tr>
<td width="100">
<vllabel errclass="error" validators="NameReq" for="Name" cerrclass="controlerror">Name:</vllabel>
</td>
<td width="220">
<input name="Name" type="text" class="control" id="Name" size="20">
<vlvalidator name="NameReq" type="required" control="Name" errmsg="Name required">
</td>
<td width="300" rowspan="5" valign="top">
<vlsummary class="error" headertext="Error(s) found:" displaymode="bulletlist">
</td>
</tr>
<tr>
<td>
<vllabel errclass="error" validators="EmailReq,Email" for="Email" cerrclass="controlerror">E-mail:</vllabel>
</td>
<td>
<input name="Email" type="text" class="control" id="Email" size="20">
<vlvalidator name="EmailReq" type="required" control="Email" errmsg="E-mail required">
<vlvalidator name="Email" type="format" format="email" control="Email" errmsg="Invalid E-mail">
</td>
</tr>
<tr>
<td colspan="2">
<vllabel errclass="error" validators="MessageReq" for="Message" cerrclass="controlerror">Message/Question:</vllabel>
</td>
</tr>
<tr>
<td colspan="2">
<textarea name="Message" cols="40" rows="7" wrap="virtual" class="control" id="Message"></textarea>
<vlvalidator name="MessageReq" type="required" control="Message" errmsg="Message required">
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" class="control" value="Send">
<input type="reset" class="control" value="Reset">
</td>
</tr>
</table>
</form>
</body>
</html>
<?php VDEnd(); ?>
<?php
define('VDAEMON_PARSE', false);
include('vdaemon.php');
$sSendTo = 'support@yoursite.com';
$sName = $_POST['Name'];
$sEmail = $_POST['Email'];
$sBuffer = "----- Quick Contact Info --------------------\n".
"Customer Name: $sName\n".
"Customer E-mail: $sEmail\n".
"Customer Message: \n\n" . wordwrap($_POST['Message'] . "\n", 48) .
"---------------------------------------------\n\n";
// Uncomment next line for real mailing
// mail($sSendTo, "Quick contact message from $sName", $sBuffer, "From: $sEmail\r\nReply-To: $sEmail\r\n");
?>
<html>
<head>
<title>Quick Contact Form Sample</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="samples.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>Quick Contact Form Sample</h1>
<p>Your message has been sent to our support staff</p>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="100" class="default">Name:</td>
<td width="300" class="default"><?php echo $_POST['Name']; ?></td>
</tr>
<tr>
<td class="default">E-mail:</td>
<td class="default"><?php echo $_POST['Email']; ?></td>
</tr>
<tr>
<td class="default">Message:</td>
<td class="default"><?php echo $_POST['Message']; ?></td>
</tr>
</table>
</body>
</html>