Changeset 1122

Show
Ignore:
Timestamp:
10/16/08 21:57:53 (3 months ago)
Author:
laurentj
Message:

ticket #718: jForms: space only values on required fields do not fire errors. patch on the 1.0.x branch. p=bibo

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0.x/lib/jelix-www/js/jforms.js

    r952 r1122  
    33* @subpackage   forms 
    44* @author       Laurent Jouanneau 
    5 * @contributor  Julien Issler 
     5* @contributor  Julien Issler, Dominique Papin 
    66* @copyright    2007 Laurent Jouanneau 
    7 * @copyright    2008 Julien Issler 
     7* @copyright    2008 Julien Issler, 2008 Dominique Papin 
    88* @link         http://www.jelix.org 
    99* @licence      GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    6060            if (!elt) continue; // sometimes, all controls are not generated... 
    6161            var val = this._getValue(elt); 
    62             if(val == ''){ 
     62            var trimVal = val; 
     63            if (val.replace) 
     64                var trimVal = val.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); 
     65            if(trimVal == ''){ 
    6366                if(c.required){ 
    6467                    f.errorDecorator.addError(c, 1); 
  • branches/1.0.x/lib/jelix/forms/jFormsControl.class.php

    r1020 r1122  
    55* @author      Laurent Jouanneau 
    66* @contributor Loic Mathaud, Dominique Papin 
    7 * @copyright   2006-2007 Laurent Jouanneau, 2007 Dominique Papin 
     7* @copyright   2006-2007 Laurent Jouanneau, 2007-2008 Dominique Papin 
    88* @copyright   2007 Loic Mathaud 
    99* @link        http://www.jelix.org 
     
    3939 
    4040    function check($value, $form){ 
    41         if($value == '') { 
     41        if(trim($value) == '') { 
    4242            if($this->required) 
    4343                return jForms::ERRDATA_REQUIRED; 
     
    115115            } 
    116116        }else{ 
    117             if($value == ''){ 
     117            if(trim($value) == ''){ 
    118118                if($this->required) 
    119119                    return jForms::ERRDATA_REQUIRED; 
     
    165165            } 
    166166        }else{ 
    167             if($value == '' && $this->required){ 
     167            if(trim($value) == '' && $this->required){ 
    168168                return jForms::ERRDATA_REQUIRED; 
    169169            }elseif(!$this->datatype->check($value)){ 
  • branches/1.0.x/testapp/modules/jelix_tests/tests/jforms.check_datas.html_cli.php

    r851 r1122  
    44* @subpackage  unittest module 
    55* @author      Jouanneau Laurent 
    6 * @contributor 
    7 * @copyright   2007 Jouanneau laurent 
     6* @contributor Dominique Papin 
     7* @copyright   2007 Jouanneau laurent, 2008 Dominique Papin 
    88* @link        http://www.jelix.org 
    99* @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    4545        $this->assertFalse($this->form->check()); 
    4646        $this->form->setData('nom',''); 
     47        $this->assertFalse($this->form->check()); 
     48        $this->form->setData('nom','    '); 
    4749        $this->assertFalse($this->form->check()); 
    4850        $ctrl->required = false; 
  • trunk/lib/jelix/forms/jFormsControl.class.php

    r1121 r1122  
    458458            } 
    459459        }else{ 
    460             if($value == ''){ 
     460            if(trim($value) == ''){ 
    461461                if($this->required) 
    462462                    return $this->container->errors[$this->ref] = jForms::ERRDATA_REQUIRED; 
     
    493493            } 
    494494        }else{ 
    495             if($value == '' && $this->required){ 
     495            if(trim($value) == '' && $this->required){ 
    496496                return $this->container->errors[$this->ref] = jForms::ERRDATA_REQUIRED; 
    497497            } 
Download in other formats: Unified Diff Zip Archive