public __construct()
public PHPFUI\Validator::getFunctionName() : string
public PHPFUI\Validator::getJavaScript() : string

Returns the JavaScript that is added to the page when addAbideValidator is called

public PHPFUI\Validator::getJavaScriptTemplate(string $customJavaScript) : string

Most validation JavaScript follows a standard pattern:

  • Get the element value
  • If the value is empty and not required, don't bother to validate, simply not set and does not need to be set
  • Otherwise, perform some test passed in by $customJavaScript which should return true if it validates, otherwise false

Local variables available to $customJavaScript

  • el: element being validated
  • required: boolean if input is required
  • parent: of el
  • to: el.val()
  • data: value of the data-validatorname attribute
  • from: value of element pointed to by the id data
  • param string $customJavaScript JavaScript using above variables returning true (validates) or false (not valid)
  • return string of JavaScript to be passed to setJavaScript
public PHPFUI\Validator::getValidatorName() : string
public PHPFUI\Validator::setJavaScript(string $javaScriptFunction) : self
protected bool PHPFUI\Validator::$addedToPage = false
protected string PHPFUI\Validator::$functionName
protected string PHPFUI\Validator::$javaScript
protected string PHPFUI\Validator::$validatorName
© 2024 Bruce Wells
Search Namespaces \ Classes