Mar 05, 2011, 12:26 AM
[CLOSED] [1.0]multiple validators on a single textfield
I have the following control on a page:
code behind:
javascript:
extjs:
The other validation routine compares this field to another for equality
<tbm:VMSTextField ID="txtNewPW"
runat="server"
InputType="Password"
LabelID="new_password"
AllowBlank="false"
MaxLength="50"
Validator="newPWValidator"
ValidateTo="txtOldPw" >
</tbm:VMSTextField>
It also has this codebehind property assignment:code behind:
txtNewPW.Vtype = "pwSecurityHigh"
And this is the custom VType which tests password strength:javascript:
Ext.apply(Ext.form.VTypes,{
pwSecurityHigh: function (v) {
var highSecPattern = new RegExp('(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,})$');
var res = highSecPattern.test(v);
return res;
}});
The problem is that line 2 below returns undefined for this.getErrors(value)[0]. The value I need is at [1].extjs:
validateValue: function (value) {
var error = this.getErrors(value)[0];
if (error == undefined) {
return true;
} else {
this.markInvalid(error);
return false;
}
}
Obviously this is because there are 2 validations. Any way around this? I tried overriding the ValidateValue function but did not succeed. Perhaps i could combine the 2?The other validation routine compares this field to another for equality
var newPWValidator = function (value) {
if (Ext.getCmp('txtOldPW')) {
var validateToValue = Ext.getCmp(this.validateTo).getRawValue();
if (value == validateToValue && value !== '' && validateToValue !== '') {
BtnRibWin1_btn1.disable();
return PageStrings.old_and_new_passwords_can_not_match;
}
BtnRibWin1_btn1.enable();
return true;
}
}
The problem I first see with combining is that oldPw does not always exist, and there are also multiple password strengths to test for. Presently the custom vtype functions are located in a global js file.
Last edited by Daniil; Mar 07, 2011 at 9:09 PM.
Reason: [CLOSED]