clientside_validation_fapi.module in Clientside Validation 7.2
Same filename and directory in other branches
Add client side validation support for fapi validation
File
clientside_validation_fapi/clientside_validation_fapi.moduleView source
<?php
/**
* @file
* Add client side validation support for fapi validation
*/
/**
* Implements hook_ctools_plugin_directory().
*/
function clientside_validation_fapi_ctools_plugin_directory($module, $plugin) {
if ($module == 'clientside_validation') {
return 'plugins/' . $plugin;
}
}
/**
* Implements hook_menu().
*/
function clientside_validation_fapi_menu() {
$items = array();
$items['clientside_validation/regex-pcre'] = array(
'title' => 'Clientside validation regex ajax callback',
'page callback' => '_clientside_validation_ajax_regex_pcre',
'access arguments' => array(
'access content',
),
'type' => MENU_CALLBACK,
);
return $items;
}
function _clientside_validation_ajax_regex_pcre() {
$param = $_POST['param'];
$value = $_POST['value'];
$result = array();
foreach ($param['expressions'] as $key => $regex) {
if (!(bool) preg_match($regex, (string) $value)) {
$result = array(
'result' => FALSE,
'message' => $param['messages'][$key],
);
break;
}
}
if (empty($result)) {
$result = array(
'result' => TRUE,
);
}
drupal_json_output($result);
}
Functions
Name | Description |
---|---|
clientside_validation_fapi_ctools_plugin_directory | Implements hook_ctools_plugin_directory(). |
clientside_validation_fapi_menu | Implements hook_menu(). |
_clientside_validation_ajax_regex_pcre |