Link to home
Start Free TrialLog in
Avatar of shuittny
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.ControlToValidate = txtBox1.text
      regExpVal.ValidationExpression = (d{2})
     
 
    ' if textbox1.text not(regExpVal.ValidationExpression) 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
Avatar of JayWhite
JayWhite

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
Avatar of shuittny

ASKER

True,

       I'm embedding the regularexpressionvalidation 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.
Use Validate method of each validator and check their IsValid or Page's IsValid properties

Ramuncikas
ASKER CERTIFIED SOLUTION
Avatar of b1xml2
b1xml2
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial