How to add validation to radio and checkbox fields
Joomla! formvalidation currently only can validate the following:
  • required (used for text field etc)
  • validate-username
  • validate-password
  • validate-numeric
  • validate-email

We have developed a plugin the replaces the standard formvalidation, which contains all the above plus:
  • validate-radio
  • validate-checkbox

BF Validate Plugin

This plugin can be download from our free download page.

BF Validate -- This plugin provides formvalidation. It adds radio and checkbox field validation functionality which Joomla! 1.5.x currently lacks.
 
Usage:
The following code is already included in BF Survey v1.4 or greater.

Include the code below instead of the usual JHTML::_('behavior.formvalidation');
BFBehavior::formbfvalidation();
 
For radio validation, include the class in the radio tag
class="required validate-radio"

For checkbox validation, include the class in the checkbox tag
class="required validate-checkbox"
 
Don't forget to publish this plugin!


In the form tag, you must include
 class="form-validate" onSubmit="return myValidate(this);"

If you want to ensure that plugin is installed, use this code
// Check that the class exists before trying to use it
if (class_exists('BFBehavior')) {
 BFBehavior::formbfvalidation();
}
?>

Example

<script language="javascript">
function myValidate(f) {
 if (document.formvalidator.isValid(f)) {
  f.check.value='';//send token
  return true;
 }
 else {
  alert('Some values are not acceptable.  Please retry.');
 }
 return false;
}
</script>

< form id="WV-form" method="post" class="form-validate" onSubmit="return myValidate(this);">

<input type="radio" name="group1" value="Milk" <?php echo 'class=" required validate-radio"'; ?> > Milk<br>
<input type="radio" name="group1" value="Butter" <?php echo 'class=" required validate-radio"'; ?> > Butter<br>
<input type="radio" name="group1" value="Cheese" <?php echo 'class=" required validate-radio"'; ?> > Cheese

</form>

 

 

 

Try our software on your own website to see if it will suit your needs....yours FREE