|
-
Oct 6th, 2005, 04:57 PM
#1
Thread Starter
Frenzied Member
Check if Textbox input is numeric
Hi ,
I am trying to check for a numeric input. I had this procedure in windows app and Im trying to put it in web but Im getting an error on
ctl.text in the code below
any ideas how I can correct this pleased.. Many thanks
VB Code:
Private Sub Submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Submit.Click
Dim bLoop As Boolean = True
Do While bLoop = True
bLoop = False
Dim ctl As Control
For Each ctl In Me.Controls 'checks to see if all required textboxes have been completed
If [B]Trim([COLOR=RoyalBlue]ctl.Text[/COLOR]) [/B] = "" And TypeOf ctl Is TextBox Then
Msgbox("Please make entry for " & ctl.ID.ToString)
bLoop = True
End If
Next
Select Case False 'check for numeric entry
Case CheckNumeric(txtmobile.Text)
txtmobile.Text = Not (IsNumeric("Mobile"))
bLoop = True
Case CheckNumeric(HomeTel.Text)
HomeTel.Text = Not (IsNumeric("HomeTel"))
bLoop = True
End Select
Loop
Last edited by angelica; Oct 6th, 2005 at 05:27 PM.
-
Oct 6th, 2005, 06:28 PM
#2
Addicted Member
Re: Check if Textbox input is numeric
I'm guessing its a build error? Its probably because the property "Text" does not belong to a generic control.
Rather than declaring ctl as a control, declare it as a textbox.
-
Oct 7th, 2005, 02:54 AM
#3
Thread Starter
Frenzied Member
Re: Check if Textbox input is numeric
hi,
It's the case alright, clt.text is not a member.
Now I thought of insstead giving a message in a RequiredFieldValidator. I know you match it with the ControlToValidate. I need to know how to use them in something like this:
VB Code:
If Not ctl Is Nothing Then
If ctl.Text.Length = 0 Then
(validator + ID).ToString.text = ("Please make entry for " & ctl.ID.ToString))
End If
But its not the right syntax. can someone please correct me or guide for some insturctions on how it works.
Thanks
-
Oct 7th, 2005, 06:08 AM
#4
Re: Check if Textbox input is numeric
Why aren't you doing this at design time, on the page itself?
-
Oct 7th, 2005, 07:34 AM
#5
Thread Starter
Frenzied Member
Re: Check if Textbox input is numeric
Mendhak, I dont know how to use the blessed required field validation! and I also want to check if all my textboxes are null, how can I??
-
Oct 7th, 2005, 07:50 AM
#6
Re: Check if Textbox input is numeric
-
Oct 7th, 2005, 01:48 PM
#7
Thread Starter
Frenzied Member
Re: Check if Textbox input is numeric
-
Oct 8th, 2005, 04:32 PM
#8
Thread Starter
Frenzied Member
Re: Check if Textbox input is numeric
Mendhak,
Those tutorials are very good. I have done a validation to my textboxes and they are working fine. There is two thing I need to clear but
1. How do I validate that its a valid email address ?
2. Since I have done these validations the data is not going into my database any longer. Am I missing something??
-
Oct 10th, 2005, 04:47 PM
#9
Fanatic Member
Re: Check if Textbox input is numeric
Angelica,
You can write a regular expression to validate your email addresses
or just look for the basic construsctors i.e. must contain the @ then a dot(.)
if you do a search on this forum or the web I'm sure you'll find some prewritten ones
showThread
-
Oct 10th, 2005, 05:22 PM
#10
Re: Check if Textbox input is numeric
The regular expression would look like:
[\w\_\.]+@[\w\_]+.(?:com|org|net)
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|