In this example, FormMail is configured to validate user input. View demo.
<html> <head><title>Just testing</title></head> <body> <form method="post" action="http://www.uic.edu/htbin/cgiwrap/bin/formmail/FormMail/depts/accc/forms/formmail/example-1.txt"> <h1>Example of FormMail 3.0</h1> This example shows the use of input validation.<br> This must be nonnull: <input type="text" name="nonnull"><br> This should be a NetID: <input type="text" name="NetID"><br> This should be an email address: <input type="text" name="email"><br> This should be a phonenumber with 5 digits: <input type="text" name="phone5"><br> This should be a phonenumber with 10 digits: <input type="text" name="phone10"><br> This should be just digits: <input type="text" name="digits"><br> This input is not checked: <input type="text" name="stuff2"><br> <hr> <input type="submit" value="Submit the form"> </form> </body> </html>
<!DOCTYPE form SYSTEM 'FormMail-3.0.dtd'> <form name="example1" > <!-- List all the fields needing server-side validation --> <validate name="nonnull" public="The nonnull field" vtype="nonnull"> <validate name="NetID" public="The NetID field" vtype="NetID"> <validate name="phone5" public="The 5 digit phone field" vtype="phone5"> <validate name="phone10" public="The 10 digit phone field" vtype="phone10"> <validate name="digits" public="The digits field" vtype="digits"> <validate name="email" public="The email field" vtype="email"> <!-- This prevents any mail being sent for this example --> <mail name="mail2" nomail> <!-- Here's the html response when all input is valid Note that the full html page is generated, including the <html>...</html> tags --> <response name="r0" > <![CDATA[ <html><head><title>Junk</title></head><body> <h1> Thank You for Submitting your Info</h1> The nonnull field was: $nonnull<br> The email field was: $email<br> The NetID field was: $NetID<br> The 5 digit phone field was: $phone5<br> The 10 digit phone field was: $phone10<br> The digits field was: $digits<br> </response> ]]> <!-- This response only kicks in if $stuff2 (ie the value for the field that wasn't checked) is not blank --> <response name="r1" if="$stuff2" > <![CDATA[ The unchecked field was filled in and is: $stuff2<br> ]]> </response> <!-- And finally, the end! --> <response name="r2" > <![CDATA[ The date is $fm_date.<br> </body></html> ]]> </response> </form>