clonefish logo

user-defined custom validation php javascript js

user-defined (custom) validation

Using custom validation, you can define your own validation expression for any element. This way you can use any complicated validation on demand, including AJAX calls.

The < and > sign in the configuration are to be taken literally: you can use these special tags to refer to generated element variables. For example,

<FORM.username>.length > 0 
in a custom JavaScript validation would be turned to
document.forms["input"]["name"].value.length > 0
automatically by Clonefish: this reference is a cross browser way to access the input element accepted by every single browser which support JavaScript.

Possible parameters:
'validation' => Array(
  Array( 
    'type' => 'custom',
    'php'  => 'strlen( <FORM.fieldname> ) > 0', // php expression
    'js'   => '<FORM.fieldname>.length > 0',    // javascript expression
  )
)