BareMetal.com

Baremetal
My Account
Domain Registration Management Services
Web Services
Rates and Specs
Bulk Rates
CGI Library
FAQ
Order Form
Tech Support
Billing Info
Company Info
Charities
Legal Info
Employment
Privacy Statement

BM


Web Services

Mandatory Fields;

Return CGI Library
Return Form Handling

This gadget supports two methods of enforcing which fields can not be empty.

The first method is the simplest to do, but doesn't produce very friendly error messages. To use this method, simply include a hidden field called MANDATORY with a value that lists all the fields you want to force the browser to fill in before submitting (separate the field names with spaces).

example:

<input type="hidden" name="MANDATORY" value="FROM TO SUBJECT" />

Here it is in action:

Enter your e-mail address: 
          Enter a subject: 
          

If you tried that, you might have noticed that the error messages aren't exactly user friendly. The solution is to use the second method:

A better solution is to specify your own error message for each field. You can do this by specifying a hidden field named after the variable you want to make mandatory, but with a "mandatory-" prefix.

Ex. To make the FROM variable mandatory, and to set the error message to "You must specify your return e-mail address."

<input type="hidden" name="mandatory-FROM" value="You must specify your return e-mail address." />

This starts to get a little tricky when you add HTML to your error message :-(. Old and new browsers disagree about when tags without proper quotes end. With the new browsers, you can simply drop all the quotes inside your error message and it will work, but you'll seriously confuse the older browsers (even Netscape 1).

The proper solution is to replace all the <, >, and " characters with their "tag" equivalents... (e.g. < becomes &lt; > becomes &gt; and " becomes &quot;)

Expressing this becomes complicated... Cut this example from the screen and NOT the "view source".

To get:

value="You <b>must</b> enter your e-mail address."

you'll have to write:

value="You &lt;b&gt;must&lt;/b&gt; enter your e-mail address."

However the result is worth the effort, especially when you add in the ERRORFTR and ERRORHDR values (which can set a header and a footer for the error page):

Enter your e-mail address: 
          Enter a subject: 
          

If there are multiple "mandatory-" fields missing, then all the errors will be displayed separated by <P> tags.

At some point you will have to ask yourself "How fancy do I want to get?" ... the good news is that it's your choice... :-).



 
Home Page    Domain Registration Services    Web Services    Technical Support
About Baremetal    Privacy Statement    Billing Info    Charities
My Account    Legal Info    Search BareMetal

Copyright 1996-2012, BareMetal.com Inc.
Last updated: Thursday, 28-May-2015 16:14:55 PDT
Last Accessed from: No-one!
Questions and comments to support@baremetal.com