MXML 部分:

<myValidators:PwdValidator />

 

Actionscript 部分:

package myValidators
{

import mx.validators.Validator;
import mx.validators.ValidationResult;
public class PwdValidator extends Validator {

[Property("rePwd")]
private var m_rePwd:String;
public function set rePwd(value:String):void
{
m_rePwd=value;
}
public function get rePwd():String
{
return m_rePwd;
}
private var results:Array;
public function PwdValidator() {

super();
}

override protected function doValidation(value:Object):Array {

results = [];

results = super.doValidation(value);

if (results.length > 0)
return results;

if(value.toString().length<6||value.toString().length>20)
{
results.push(new ValidationResult(true, null, "tooShort",
"密码必须是6-20位"));
return results;
}
if(value.toString()!=rePwd)
{
results.push(new ValidationResult(true, null, "different",
"两次密码输入必须相同"));
return results;
}

return results;
}
}
}

相关文章:

  • 2022-12-23
  • 2022-01-07
  • 2021-07-14
  • 2021-12-31
  • 2022-12-23
  • 2021-08-07
  • 2021-09-16
猜你喜欢
  • 2021-08-02
  • 2022-03-06
  • 2022-12-23
  • 2022-12-23
  • 2022-03-04
  • 2022-12-23
  • 2021-12-04
相关资源
相似解决方案