Micro Focus QTP (UFT) Forums
Validating Password field - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Regular Expressions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Regular-Expressions)
+--- Thread: Validating Password field (/Thread-Validating-Password-field)



Validating Password field - John087 - 06-16-2012

Hi, I am brand new to QTP and I would like to know how to validate the password field using QTP. The password field has the following constraints:

Password can contain 6 to 12 characters
Must be a combination of at least 3 of the below conditions
1. Lower Case
2. Upper Case
3. Numerics
4. Special Characters like (@#$%^&*-)

Example: Password123, P@12346, pass@123 etc. etc.

Would be great if you can help me out.

Thank You




RE: Validating Password field - Ankesh - 06-18-2012

Hi,

You need to use regular expression for that.Try the below one.
Code:
Set RegEx = CreateObject("VBScript.RegExp")  'Create Object
RegEx.Pattern = "^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[[@#$^&*_-]).{6,12}" 'Set the pattern
strResult=RegEx.Test(strText) 'Test string,Replace strText with ur pwd
If strResult=False Then
msgbox "Invalid Password"
Else
msgbox "Valid Password"
End If
Set RegEx =Nothing

Regards,
Ankesh