Getting started with validation

JimmyHill 14 Jan, 2008
Hi

My first post here ... I've got a couple of forms up and running but hit a point where I need some help please.

I'm working on a form which needs the user to agree to terms. I have a checkbox and made it required and validation enabled - correct? It seems to work but for the user there's no indication that they've failed to agree to terms ie checked the box - so I need javascript validation, correct? If so how do I do that please? - I read the thread in the How To but sorry soon got lost there.

Also how do I upgrade compont without losing my forms?

Thanks in advance

My form code below (yes I found it on here)

<fieldset>
<legend>MailShot from Jon Jackson Design for Screen & Print</legend>
<br/>
<label2 for="contact">Contact: **************</label2><br/>
<label2 for="tel">Telephone: **************</label2><br/>
<label2 for="mob">Mobile: **************</label2>
</fieldset><br/>
<fieldset>
<legend><strong>Your Details</strong></legend>
<p><label1 for="name">Your Name:</label1><input type="text" name="name" size="40"></p>
<p><label1 for="email">E-mail:</label1><input name="email" type="text" size="40">
<p><label1 for="dayphone">Day Phone:</label1><input type="text" name="day_phone" size="20">         </p>
<p><label1 for="evephone">Evening Phone:</label1><input type="text" name="night_phone" size="20"></p>
</p>
</fieldset><br />
<fieldset>
<legend><strong>When would you like this project to begin?</strong></legend>  


<br/>
<label2 for="month"><strong>Month</strong>
<select NAME="month" id="startmonth" size="1">
  <option SELECTED VALUE="none">Select Month</option>
  <option VALUE="Jan">Jan</option>
  <option VALUE="Feb">Feb</option>
  <option VALUE="Mar">Mar</option>
  <option VALUE="Apr">Apr</option>
  <option VALUE="May">May</option>
  <option VALUE="Jun">Jun</option>
  <option VALUE="Jul">Jul</option>
  <option VALUE="Aug">Aug</option>
  <option VALUE="Sep">Sep</option>
  <option VALUE="Oct">Oct</option>
  <option VALUE="Nov">Nov</option>
  <option VALUE="Dec">Dec</option>
</select></p></label2>
<br/>
<label2 for="year"><strong>Year</strong> 
  <select name="select" id="startyear" size="1">
    <option value="2008" selected="selected">2008</option>
    <option value="2009">2009</option>
  </select>
</label2>

</fieldset><br/>
<fieldset>
<legend><strong>Your Enquiry is about:</strong></legend>
<div align="left">
<table border="0" width="90%" id="table4" align="left">
  <tr>
    <td width="150">
      <p>
        <input TYPE="checkbox" NAME="mailshot" VALUE="info" id="basic">
      <label id="basic" for="basic">Mailshot </label>
      <br>
      I'll manage it all by myself.<br>
      </p>      </td>
    <td>
      <p>
        <input TYPE="checkbox" NAME="mailexist" VALUE="info" id="existing"> 
      <label id="existing" for="existing"></label>
      Customise an existing template: £90</p>
      
      <p><input TYPE="checkbox" NAME="mailown" VALUE="info" id="owndesign"> 
        <label id="owndesign" for="owndesign"></label>
        Use your design: £250</p>
      <p>
        <input TYPE="checkbox" NAME="mailcustom" VALUE="info" id="custom">
        <label id="custom" for="custom"></label>
Custom design: £600</p>
</td>
    </tr>
</table>
</div>
<p></p>
<p><textarea COLS="50" NAME="other_info" id="ff_elem192" style="height: 63; width: 612" rows="4"></textarea>
</p>
</fieldset><br/>
<fieldset>
<legend><strong>The best way to contact you is</strong></legend>

<input type="checkbox" name="contact" value="phone"> By Telephone 
<input type="checkbox" name="contact" value="email"> By Email </p>
</fieldset><br/>
<fieldset>
<legend><strong>Use the space below for additional questions & comments:</strong></legend>
<p><textarea COLS="50" NAME="other_info0" id="ff_elem205" style="height: 63; width: 612" rows="4"></textarea>
</p>
</fieldset><br/>
<fieldset>
<legend><strong>AntiSpam Policy</strong></legend>
<input type="checkbox" name="antispam" value="agree"> I agree to the AntiSpam conditions 
</fieldset><br/>
<fieldset><legend><strong>AntiSpam</strong></legend>
<div align="center">{imageverification}</div>
</fieldset>
</p>
<p align="center">
  <input type="submit" value="Apply for MailShot" name="Submit" style="font-weight: bold">       
  <input type="reset" value="Reset (cancel form)" name="reset" style="font-size: 8pt">
</p>
GreyHead 14 Jan, 2008
Hi JimmyHill,

ChronoForms validation is JavaScript validation. Here's a paragraph from Andrew Tetlaw's site that may help:

To use the validate-one-required validator you must first add the class name to only one checkbox/radio button in the group (last one is probably best) and then place all the input elements within a parent element, for example a div element. That way the library can find all the checkboxes/radio buttons to check and place the validation advice element at the bottom of the parent element to make it appear after the group of checkboxes/radio buttons.

To upgrade to 2.3.7 for Joomal 1.0.x see the file and instructions here

Bob
JimmyHill 14 Jan, 2008
Thanks Bob
I found Andrew Tetlaw's site - so am I right in thinking I need to follow Andrew's method?
GreyHead 14 Jan, 2008
Hi Jimmy,

If you are using the ChronoForms validation and have selected the default (Prototype) library* then ChronoForms uses Andrew Tetlaw's library. You need to make sure that your form html is consistent with how that works.

You have several checkboxes in your code and you don't say which one you want to validate but none of them seem to be enclosed in divs as validate-one-required needs to show the error message.

Bob

* From CF 2.3.7 there's also a MooTools library option. I think that works in a very similar way.
JimmyHill 14 Jan, 2008
Thanks again, Bob

Please forgive me if I'm missing something here, but -

How do I select the default library?

How do I ensure html consistency?

The check box I want to validate is <input type="checkbox" name="antispam" value="agree"> - do I just wrap a div around it or does the div need an id or class which is related to a css file?
JimmyHill 14 Jan, 2008
OK I've cracked it.

I just added a div around the checkbox, imported the stylesheeet and it's now working fine and dandy.

Thanks for your help ... I'll make a donation!

Cheers
Jon
GreyHead 15 Jan, 2008
Hi Jon,

Excellent, thanks for letting us know you've got it running; and for the donation.

Bob
This topic is locked and no more replies can be posted.