required validation requires checkbox input field text password textarea length option checked

required validation

  • For an inputText, inputHidden, inputPassword, textarea or FCKEditorArea2 field it examines if the length of the input field is not zero without the trailing and leading whitespace.
  • For an inputCheckbox, it requires the checkbox to be checked
  • For an inputRadio, inputRadioDynamic, a multiple select, a multiple selectDynamic or a multiple selectFile it requires at least one option to be selected
  • For inputCheckboxDynamic element (checkbox group) you can finetune how many checkboxes must be checked (min/max number)

Tips:

  • If you'd like to make an inputFile mandatory, you'll need to use the 'required' parameter of the file validation.
  • You can achieve the opposite of this validation using the 'required' parameter available for several validation types: this way you can accept valid or empty fields, for example a valid number OR an empty field.

<?php  

$config 
= Array(    

  
'element' => Array(    

    
'type' => '...',    
    
// ...further element settings here...    

    
'validation' => Array(     

      Array(

        
'type'    => 'required'
 
        
// only for inputCheckboxDynamic:
        
'minimum' => 1// default: 1 
        
'maximum' => 5  // default: false (no maximum)
 
        
'help'    => 'Help message value for this validator only'
      
)
    )
  )
);

?>


Live examples:

form validation for developers!

clonefish is a proven, mature form generator class that helps PHP developers to create, validate and process secure, flexible and easy-to-maintain forms
learn more
Bookmark and Share