Click to See Complete Forum and Search --> : Text filed should allow only characters??
shanuragu
09-23-2005, 08:50 AM
Hi,
How can I do Character validation ie, text field should allow only characters not even special characters in VB script. Some what like IsNumeric for numbers I need a function to validate only for characters.
thnx in advance
shan
buntine
09-23-2005, 10:25 PM
Try regular expressions. VBScript has a small, but sufficient Reg Exp API.
Dim objRegExp, strField, isValid
Set objRegExp = New RegExp
With objRegExp
.Pattern = "^[a-bA-B]{1,}$"
.IgnoreCase = True
.Global = True
End With
isValid = objRegExp.Test(strField)
If isValid Then
'' Only contains letters.
Else
'' GRR! Invalid.
End If
Regards.
shanuragu
09-26-2005, 07:15 AM
Hi,
The text box (of length 15) should allow only characters. How can I do that. I tried the following but not getting exact result.
Dim objRegExp, isValid, strCheck
Set objRegExp = New RegExp
With objRegExp
.Pattern = "[A-Za-z]"
.IgnoreCase = True
.Global = True
End With
isValid = objRegExp.Test(strValue)
if Not(isValid) Then
acceptOnlyChars = False
Exit Function
End If