PDA

View Full Version : [CLOSED] custom validator



odyssey
Jan 21, 2014, 10:14 AM
Searching lilte bit on forum on custom validation I came to the following solution


Ext.apply(Ext.form.VTypes, {
validateLength: function (value) {
if (value != '') {
if (value.length < 6) {
return 'Invalid Password length!! Password must be at least 6 characters';
} else {
return true;
}
}
}
})

<ext:TextField ID="txtNewPassword" AnchorHorizontal="100%" LabelWidth="120" runat="server"
ValidateBlank="true" AllowBlank="false"
InputType="Password" BlankText="Your password is required." Vtype = "validateLength" MsgTarget="Side"
FieldLabel="New Password">
<CustomConfig>
<ext:ConfigItem Name="maxLength" Value="6" Mode="Raw">
</ext:ConfigItem>
</CustomConfig>
</ext:TextField>



Bit without luck .How to custom validate a field ??

Daniil
Jan 21, 2014, 12:25 PM
Hi @odyssey,

You are almost right.

Ext.apply(Ext.form.field.VTypes, {
validateLength: function (value) {
if (value != '') {
if (value.length < 6) {
return false;
} else {
return true;
}
}
},

validateLengthText: 'Invalid Password length!! Password must be at least 6 characters'
});
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.VTypes

odyssey
Jan 21, 2014, 3:03 PM
Thanks Daniil