Click to See Complete Forum and Search --> : calling asp function


marchnw
05-29-2008, 09:06 AM
I have the function below trying to validate my password standards. I have never used a function in asp before. How do I call and run the fuction? Is it different than a sub-routine?



Function ValidatePassword(sPW)
If Len(sPW) < 8 OR Len(sPW) > 26 Then
ValidatePassword = "Password must be between 8 and 26 characters in length"
Exit Function
End If

Dim okay : okay = 0
Dim vre
Set vre = New RegExp
vre.Pattern = "[a-z]"
If vre.Test( sPW ) Then okay = okay + 1
vre.Pattern = "[A-Z]"
If vre.Test( sPW ) Then okay = okay + 1
vre.Pattern = "[0-9]"
If vre.Test( sPW ) Then okay = okay + 1
vre.Pattern = "[\?\.\,\_\-\~\+\=\&\!]"
If vre.Test( sPW ) Then okay = okay + 1

If okay < 3 Then
ValidatePassword = "Your password is not strong enough. See the guidelines."
Else
ValidatePassword = ""
End If
End Function

yamaharuss
05-29-2008, 04:34 PM
Change the bottom part to:

If okay < 3 Then
ValidatePassword = False
Else
ValidatePassword = True
End If

Then wherever you are calling the function do:

If ValidatePassword(strWhateverPassword) then
--- DO THE GOOD STUFF
Else
--- SORRY, BAD PASSWORD
End If

Terrorke
05-30-2008, 07:56 AM
Just call the function with :
functionname(optionalparameters)
will do the trick :-)