title: Form Validation in Coldfusion
body: <p>i am trying to validate my form so it doesnt accept empty fields.
  You can see i have tried to do validation on the "Country" using the 'required' property but that doesnt work....</p>
  
  <p>I only want validation done on certain fields: Country, Address, City and ReceptionNumber</p>
  
  <p>Here is my code for the form:</p>
  
  <p></p>
  
  <pre><code>&lt;head&gt;
  
      &lt;title&gt;Office Location Entry Form&lt;/title&gt;
      &lt;LINK rel="stylesheet" type="text/css" href="css/style.css"&gt;
      &lt;cfinclude template="CheckUserLogin.cfm"&gt;
  
  &lt;/HEAD&gt;
  
  
  &lt;body background="FFFFFF" bgcolor="#FFFFFF"&gt;
  
      &lt;P class="paratitle"&gt;&lt;br&gt; Country Offices Entry Form &lt;BR&gt;
      &lt;P class="normal"&gt;Please fill in as many fields as possible. Please include the country dial code when entering phone or fax numbers.&lt;/p&gt;
  
  &lt;!--- Entry form ---&gt;
  &lt;FORM name="officeLocations" action="officeLocations_EntryAction.cfm" method="post" onSubmit="return ValidateInput(this);"&gt;
  
      &lt;TABLE&gt;
          &lt;!--- Field: office_locations.Country ---&gt;
          &lt;TR&gt;
          &lt;TD valign="top" class="normal"&gt; Country &lt;/TD&gt;
          &lt;TD valign="top" class="normal"&gt;
  
          &lt;input type="text" name="Country" size="30" maxlength="510" class="input" required="yes" message="You must enter a first country."&gt; 
      &lt;/TD&gt;
      &lt;/TR&gt;
  
  
      &lt;!--- Field: office_locations.address ---&gt;
      &lt;TR&gt;
      &lt;TD valign="top" class="normal"&gt; Address&lt;/TD&gt;
      &lt;TD valign="top" class="normal"&gt;
  
          &lt;INPUT type="text" name="address" size="30" value="" maxLength="510" class="input"&gt;
  
      &lt;/TD&gt;
      &lt;/TR&gt;
  
      &lt;!--- Field: office_locations.address2 ---&gt;
      &lt;TR&gt;
      &lt;TD valign="top" class="normal"&gt; Address 2&lt;/TD&gt;
      &lt;TD valign="top" class="normal"&gt;
  
          &lt;INPUT type="text" name="address2" size="30" value="" maxLength="510" class="input"&gt;
  
      &lt;/TD&gt;
      &lt;/TR&gt;
  
      &lt;!--- Field: office_locations.address3---&gt;
      &lt;TR&gt;
      &lt;TD valign="top" class="normal"&gt; Address 3&lt;/TD&gt;
      &lt;TD valign="top" class="normal"&gt;
  
          &lt;INPUT type="text" name="address3" size="30" value="" maxLength="510" class="input"&gt;
  
      &lt;/TD&gt;
      &lt;/TR&gt;
  
      &lt;!--- Field: office_locations.address5---&gt;
      &lt;TR&gt;
      &lt;TD valign="top" class="normal"&gt; Address 4&lt;/TD&gt;
      &lt;TD valign="top" class="normal"&gt;
  
          &lt;INPUT type="text" name="address4" size="30" value="" maxLength="510" class="input"&gt;
  
      &lt;/TD&gt;
      &lt;/TR&gt;
  
      &lt;!--- Field: office_locations.address4 ---&gt;
      &lt;TR&gt;
      &lt;TD valign="top" class="normal"&gt; City&lt;/TD&gt;
      &lt;TD valign="top" class="normal"&gt;
  
          &lt;INPUT type="text" name="city" size="30" value="" maxLength="510" class="input"&gt;
  
      &lt;/TD&gt;
      &lt;/TR&gt;
  
      &lt;!--- Field: office_locations.postcode ---&gt;
      &lt;TR&gt;
      &lt;TD valign="top" class="normal"&gt; Postal code&lt;/TD&gt;
      &lt;TD valign="top" class="normal"&gt;
  
          &lt;INPUT type="text" name="postcode" size="30" value="" maxLength="510" class="input"&gt;
  
      &lt;/TD&gt;
      &lt;/TR&gt;
  
      &lt;!--- Field: office_locations.receptionnumber ---&gt;
      &lt;TR&gt;
      &lt;TD valign="top" class="normal"&gt; Reception number&lt;/TD&gt;
      &lt;TD valign="top" class="normal"&gt;
  
          &lt;INPUT type="text" name="receptionnumber" size="30" value="" maxLength="510" class="input"&gt;
  
      &lt;/TD&gt;
      &lt;/TR&gt;
  
      &lt;!--- Field: office_locations.mainnumber ---&gt;
      &lt;TR&gt;
      &lt;TD valign="top" class="normal"&gt; Main number&lt;/TD&gt;
      &lt;TD valign="top" class="normal"&gt;
  
          &lt;INPUT type="text" name="mainnumber" size="30" value="" maxLength="510" class="input"&gt;
  
      &lt;/TD&gt;
      &lt;/TR&gt;
  
      &lt;!--- Field: office_locations.faxnumber ---&gt;
      &lt;TR&gt;
      &lt;TD valign="top" class="normal"&gt; Fax number&lt;/TD&gt;
      &lt;TD valign="top" class="normal"&gt;
  
          &lt;INPUT type="text" name="faxnumber" size="30" value="" maxLength="510" class="input"&gt;
  
      &lt;/TD&gt;
      &lt;/TR&gt;
  
  
      &lt;INPUT type="hidden" name="timestamp" value="&lt;CFOUTPUT&gt;#DateFormat(Now())#, #TimeFormat(Now())#&lt;/CFOUTPUT&gt;" size=""&gt;
      &lt;INPUT type="hidden" name="username" value="&lt;CFOUTPUT&gt;#Session.FirstName# #Session.LastName#&lt;/CFOUTPUT&gt;" size=""&gt;
      &lt;INPUT type="hidden" name="NTusername" value="&lt;cfoutput&gt;#Session.NtUserName#&lt;/cfoutput&gt;" size=""&gt;
  &lt;/TABLE&gt;
  &lt;P&gt;
  &lt;input type="image" src="IMAGES/AddItButton.gif" align="absmiddle"&gt;
  
  &lt;/FORM&gt;
  
  &lt;/body&gt;
  
  
  
  &lt;/html&gt;&lt;/HTML&gt;
  </code></pre>
  
  <p>Thanks</p>