actionscript 3 - Action Script 3 NumericStepper validation for empty value -


i have simple numericstepper looks this:

<mx:numericstepper id="nsport" minimum="0" maximum="65535" stepsize="1" value="{port_default}"/> 

i wrote validator (which doesn't work expect):

<mx:numbervalidator required="true" source="{nsport}" property="value"/> 

however, every time don't enter numericstepper passes zero, not null or else, is...well...a valid value. suspect done on purpose. so, how can make blank value @ numbericstepper invalid? please note i'm restricted ver.3 of action script.

example code base https://flexscript.wordpress.com/2008/09/22/flex-creating-custom-validators/ little modification:

package flexscript {      import mx.validators.validationresult;      import mx.validators.validator;   //class should extend mx.validators.validator  public class numericsteppervalidator extends validator {          public function numericsteppervalidator() {             // call base class constructor.             super();         }          // class should override dovalidation() method.         //dovalidation method should accept object type parameter         override protected function dovalidation(value:object):array {             // create array return.             var validatorresults:array = new array();             // call base class dovalidation().             validatorresults = super.dovalidation(value);                    // return if there errors.             if (validatorresults.length > 0)                 return validatorresults;              if (string(value).length == 0)              return validatorresults;             if ( value == 0)//as required.              return validatorresults;                 var regpattern:regexp = /\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/; //change customize regexpression             var a:array = regpattern.exec(string(value));                if (a == null)                {                 validatorresults.push(new validationresult(true, null, "numbericstepper error","you must enter number"));                 return validatorresults;                }              return validatorresults;         }     } }  <flexscript:numbericsteppervalidator source="{{nsport}}" property="number"/> 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -