parents-merge 41566 - Updated required validator to not allow a sequence of whitespace as a value

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@45062 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2007-11-19 02:05:56 +00:00
parent 202b7fd9b6
commit cc97834409
2 changed files with 2 additions and 4 deletions

View File

@ -60,7 +60,7 @@ class CustomRequiredFields extends RequiredFields{
eval($field['php']);
}else if($fields->dataFieldByName($field)) {
// if an error is found, the form is returned.
if(!$data[$field]) {
if(!$data[$field] || preg_match('/^\s*$/', $data[$field])) {
$this->validationError(
$field,
sprintf(_t('Form.FIELDISREQUIRED', "%s is required"), $field),

View File

@ -95,8 +95,6 @@ function require(fieldName,cachedError) {
var set = el.value;
}
var baseEl;
// Sometimes require events are triggered of
@ -132,7 +130,7 @@ function require(fieldName,cachedError) {
}
// This checks to see if the input has a value, and the field is not a readonly.
if((typeof set == 'undefined' || set == "")) {
if( ( typeof set == 'undefined' || (typeof(set) == 'string' && set.match(/^\s*$/)) ) ) {
//fieldgroup validation
var fieldLabel = findParentLabel(baseEl);