shuittny
asked on
checking to see if a textbox control is valid
Does anyone know how to check if a textbox value passes a regular validation value. I can do it easily from the grid approach but not via actual code
ex.
sub customFunc(......)
Dim regExpVal as RegularExpressionValidator
regExpVal.ControlToValidat e = txtBox1.text
regExpVal.ValidationExpres sion = (d{2})
' if textbox1.text not(regExpVal.ValidationEx pression) then ........I'm not sure if this is valid or would work if it is valid
response.write("this field isn't a valid field")
end if
end sub
ex.
sub customFunc(......)
Dim regExpVal as RegularExpressionValidator
regExpVal.ControlToValidat
regExpVal.ValidationExpres
' if textbox1.text not(regExpVal.ValidationEx
response.write("this field isn't a valid field")
end if
end sub
use Page.IsValid to know if your page is valid.
Wouldn't it be more simple way to set RegularExpressionValidator control on a page and set it's ControlToValidate, ValidationExpression, Display, ErrorMessage, EnableClientScript properties to desired values. Then all you have to do is
If Page.IsValid Then
'do your desired processing
Else
'tell user that input was incorrect
End If
Ramuncikas
If Page.IsValid Then
'do your desired processing
Else
'tell user that input was incorrect
End If
Ramuncikas
ASKER
True,
I'm embedding the regularexpressionvalidatio n within a custom validation script that I wrote. I origninally have a reg.exp.val for all of my textboxes along with a custom val for those same textboxes. I just wanted to see if I could combine everything into one call.
I'm embedding the regularexpressionvalidatio
Use Validate method of each validator and check their IsValid or Page's IsValid properties
Ramuncikas
Ramuncikas
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.