?
Solved

checking to see if a textbox control is valid

Posted on 2005-05-17
6
Medium Priority
?
181 Views
Last Modified: 2010-04-07
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
0
Comment
Question by:shuittny
5 Comments
 
LVL 1

Expert Comment

by:JayWhite
ID: 14018848
use Page.IsValid to know if your page is valid.
0
 
LVL 14

Expert Comment

by:Ramuncikas
ID: 14018918
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
0
 

Author Comment

by:shuittny
ID: 14019492
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.
0
 
LVL 14

Expert Comment

by:Ramuncikas
ID: 14019549
Use Validate method of each validator and check their IsValid or Page's IsValid properties

Ramuncikas
0
 
LVL 23

Accepted Solution

by:
b1xml2 earned 300 total points
ID: 14020357
if the CustomValidators are all hooked up at Page_Init or Page_Load then all you have to do is:
Page.Validate() 'calling the page validate method causes all validators to be validate
If Page.IsValid Then

End If
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question