Hi,
Is there a way to create a CustomValidator that works like a RegularExpressionValidator?
I've got a web application with a RadioButtonList, four textboxes, and a submit button. Depending on which radiobutton is checked, different textboxes must be filled in. (ie: if the first radiobutton is checked, the first two textboxes must be filled in; if the second radiobutton is checked, the second two textboxes must be filled in)
A while ago, I needed a RequiredFieldValidator (if the first rb is checked, I needed to make sure the first two textboxes weren't blank). Because this check was conditional, I had to make a CustomValidator that worked the same as a RFV since I couldn't make a conditional RFV.
Now I have a problem where, if the user clicks the first radiobutton, I need to make sure the user only entered alphanumeric data. Since I can't make the RegularExpressionValidator conditional, I figured I'd make it a Custom Validator. I just don't know how to check for a regular expression in my function.
I saw something like this:
If(me.txtAST.Text Like "[0-9A-Za-z]")
' Alphanumeric data
Else
' Nonalphanumeric data
But the IF statement will fail no matter what data I enter (00001, 00002, 0001A, etc). I'd like it to work the same way as if I had a RegularExpressionValidator with the ValidationExpression set to "\w{5}"
Any ideas??
Thanks in advance,
Suzanne
Is there a way to create a CustomValidator that works like a RegularExpressionValidator?
I've got a web application with a RadioButtonList, four textboxes, and a submit button. Depending on which radiobutton is checked, different textboxes must be filled in. (ie: if the first radiobutton is checked, the first two textboxes must be filled in; if the second radiobutton is checked, the second two textboxes must be filled in)
A while ago, I needed a RequiredFieldValidator (if the first rb is checked, I needed to make sure the first two textboxes weren't blank). Because this check was conditional, I had to make a CustomValidator that worked the same as a RFV since I couldn't make a conditional RFV.
Now I have a problem where, if the user clicks the first radiobutton, I need to make sure the user only entered alphanumeric data. Since I can't make the RegularExpressionValidator conditional, I figured I'd make it a Custom Validator. I just don't know how to check for a regular expression in my function.
I saw something like this:
If(me.txtAST.Text Like "[0-9A-Za-z]")
' Alphanumeric data
Else
' Nonalphanumeric data
But the IF statement will fail no matter what data I enter (00001, 00002, 0001A, etc). I'd like it to work the same way as if I had a RegularExpressionValidator with the ValidationExpression set to "\w{5}"
Any ideas??
Thanks in advance,
Suzanne