Minor - format code

pull/2487/head
jmontoyaa 10 years ago
parent cb73e6d214
commit c6b47fbc05
  1. 21
      main/inc/lib/pear/HTML/QuickForm.php
  2. 19
      main/inc/lib/pear/HTML/QuickForm/Rule/Regex.php

@ -1065,8 +1065,9 @@ class HTML_QuickForm extends HTML_Common
}
}
}
return $el;
} // end func removeElement
}
/**
* Adds a validation rule for the given field
@ -1086,7 +1087,7 @@ class HTML_QuickForm extends HTML_Common
* @access public
* @throws HTML_QuickForm_Error
*/
function addRule(
public function addRule(
$element,
$message,
$type,
@ -1148,15 +1149,17 @@ class HTML_QuickForm extends HTML_Common
$this->_rules[$element] = array();
}
if ($validation == 'client') {
$this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_' . $this->_attributes['id'] . '; } catch(e) { return true; } return myValidator(this);'));
$this->updateAttributes(
array('onsubmit' => 'try { var myValidator = validate_' . $this->_attributes['id'] . '; } catch(e) { return true; } return myValidator(this);')
);
}
$this->_rules[$element][] = array(
'type' => $type,
'format' => $format,
'message' => $message,
'validation' => $validation,
'reset' => $reset,
'dependent' => $dependent
'type' => $type,
'format' => $format,
'message' => $message,
'validation' => $validation,
'reset' => $reset,
'dependent' => $dependent,
);
}

@ -41,13 +41,13 @@ class HTML_QuickForm_Rule_Regex extends HTML_QuickForm_Rule
* @var array
* @access private
*/
var $_data = array(
'lettersonly' => '/^[a-zA-Z]+$/',
'alphanumeric' => '/^[a-zA-Z0-9]+$/',
'numeric' => '/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/',
'nopunctuation' => '/^[^().\/\*\^\?#!@$%+=,\"\'><~\[\]{}]+$/',
'nonzero' => '/^-?[1-9][0-9]*/'
);
public $_data = array(
'lettersonly' => '/^[a-zA-Z]+$/',
'alphanumeric' => '/^[a-zA-Z0-9]+$/',
'numeric' => '/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/',
'nopunctuation' => '/^[^().\/\*\^\?#!@$%+=,\"\'><~\[\]{}]+$/',
'nonzero' => '/^-?[1-9][0-9]*/',
);
/**
* Validates a value using a regular expression
@ -57,7 +57,7 @@ class HTML_QuickForm_Rule_Regex extends HTML_QuickForm_Rule
* @access public
* @return boolean true if value is valid
*/
function validate($value, $regex = null)
public function validate($value, $regex = null)
{
// Fix for bug #10799: add 'D' modifier to regex
if (isset($this->_data[$this->name])) {
@ -98,5 +98,4 @@ class HTML_QuickForm_Rule_Regex extends HTML_QuickForm_Rule
return array(" var regex = " . $regex . ";\n", "{jsVar} != '' && !regex.test({jsVar})");
} // end func getValidationScript
} // end class HTML_QuickForm_Rule_Regex
?>
}
Loading…
Cancel
Save