Flex Password match check
Ever wanted to do a flex form with a password retype check in it ?
Well look no further I‘ve got the right script for you right here. This little class file checks if Passwords Match before Form is submitted.
The small code to do this check is :
<validator:StringMatchValidator id="passwordMatchValidator"<br /><br />
source="{password2}"<br /><br />
property="text"<br /><br />
matches="{password1.text}" /><br /><br />
<br /><br />
And just add this class to your project for the actual checking of the password match.
<br /><br />
<br /><br />
package validator<br /><br />
{<br /><br />
import mx.validators.ValidationResult;<br /><br />
import mx.validators.Validator;<br /><br />
<br /><br />
public class StringMatchValidator extends Validator {<br /><br />
<br /><br />
// Define Array for the return value of doValidation().<br /><br />
private var results:Array;<br /><br />
<br /><br />
// Define compare string<br /><br />
private var _matches : String = "";<br /><br />
<br /><br />
// Define mismatch error messsage<br /><br />
private var _mismatchError : String = "Password Dosen't match Retype!";<br /><br />
<br /><br />
// Constructor.<br /><br />
public function StringMatchValidator() {<br /><br />
super();<br /><br />
}<br /><br />
<br /><br />
public function set matches (s : String) : void {<br /><br />
_matches = s;<br /><br />
}<br /><br />
<br /><br />
public function set mismatchError (s : String) : void {<br /><br />
_mismatchError = s;<br /><br />
}<br /><br />
<br /><br />
// Define the doValidation() method.<br /><br />
override protected function doValidation(value:Object):Array {<br /><br />
//var pwd: Password = value as Password;<br /><br />
var s1: String = _matches;<br /><br />
var s2: String = source.text;<br /><br />
<br /><br />
results = [];<br /><br />
results = super.doValidation(value);<br /><br />
<br /><br />
// Return if there are errors.<br /><br />
if (results.length > 0)<br /><br />
return results;<br /><br />
<br /><br />
if(s1 == s2)<br /><br />
{<br /><br />
return results;<br /><br />
}<br /><br />
else<br /><br />
{<br /><br />
results.push(new ValidationResult(true, null, "Mismatch", _mismatchError));<br /><br />
return results;<br /><br />
}<br /><br />
}<br /><br />
}<br /><br />
<br /><br />
}
You want to see it work ?
Just go to my small Flex Direct Admin tool : http://www.brighthost.eu/DirectAdmin/ click on the Change Email PWD menu item and go and give the flex password match check solution a try. Just fill in a New Password and do a reType Password. If you got it correct you will not get a error. If it doesn’t you will get the Red Line error message.


The URL is a 404… ;(