PDA

View Full Version : [ASK] Have a problem with My Password Validation - 2



thenevermore
12 Nov 2012, 7:34 PM
Dear all ,

i have a problem with my password validation.

my current validation is using vtype and has its own pattern like this (2 uppercase + upper/lowercase + number) -> PAssword90 or PAssWord99

you will find this rule is not user friendly to be applied because user has to obey the pattern.
Once the pattern ignored (for example : number is placed in first string -> 90Password ), error message will appear.

here my vtype :


Ext.form.VTypes=function()
{
k= /^([A-Z]{2})[A-Za-z\-]+[0-9_]+/;
return
{
passpos : function(e)
{
return k.test(e) },
passposText : "Wajib mengandung Huruf besar,huruf kecil, dan angka",
passposMask : /[A-Za-z0-9_]/i
}
}();


i want to create a rules (vtype or regEx) that allow user input their own password as long as containing one of Uppercase , number ,and symbols placed anywhere.

Example :


password -> wrong (not containing Uppercase , number and symbols)
Password -> wrong (not containing number and symbols)
pASsword -> wrong (not containing number and symbols)
pASsword90 -> wrong (not containing symbols)
pASsword90# -> correct
&pAssword99 -> correct
pas$90Word -> correct


If you have any suggestion or idea , you may share it with us here.
:D

vietits
12 Nov 2012, 9:03 PM
Try this:


Ext.apply(Ext.form.field.VTypes, {
passpos: function(v) {
return /[A-Z]+/.test(v) && /[a-z]+/.test(v) && /[0-9]+/.test(v) && /[-_~!@#$%^&]+/.test(v);
},
passposText : "Wajib mengandung Huruf besar,huruf kecil, dan angka",
passposMask : /[A-Za-z0-9_]/i
});

thenevermore
13 Nov 2012, 2:04 AM
Try this:


Ext.apply(Ext.form.field.VTypes, {
passpos: function(v) {
return /[A-Z]+/.test(v) && /[a-z]+/.test(v) && /[0-9]+/.test(v) && /[-_~!@#$%^&]+/.test(v);
},
passposText : "Wajib mengandung Huruf besar,huruf kecil, dan angka",
passposMask : /[A-Za-z0-9_]/i
});


Finally , that's worked well,,

big thanks for vietits,
:)

Case Closed
=D>