[RESOLVED] Text validation help
Visual Web Developer 2010 Express
This is an ASP.net project
I have searched but wasn't successful :(
I have two text boxes and I need to make small calculator.
I have made one "IF" for checking is there something in textboxes, if they are empty then I get message that I didn't insert anything.
And if I insert numbers then I get the result.
This is ok.
I have a problem with validation :eek:
I need ONLY numbers to be inserted, if I insert something that is not integer I need a message that this is not a number.
Please, hlp.
This is my code :
Code:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
If TextBox1.Text = ("") Or TextBox2.Text = ("") Then
Label5.Text = ("Niste unjeli dva broja, pokusajte ponovo")
Else
Dim prvi As Integer = TextBox1.Text
Dim drugi As Integer = TextBox2.Text
Label5.Text = (prvi + drugi)
End If
End Sub
Re: [RESOLVED] Text validation help
glad to hear this,
if you want to learn more about RegularExpressions
http://gskinner.com/RegExr/
Re: [RESOLVED] Text validation help
ok, great i was just want to check if it was right or wrong
you can check if the numbers was 2 digits or not
use this
Code:
System.Text.RegularExpressions.Regex("^[\d]{2}$")
Re: [RESOLVED] Text validation help
Quote:
Originally Posted by
avrail
ok, great i was just want to check if it was right or wrong
you can check if the numbers was 2 digits or not
use this
Code:
System.Text.RegularExpressions.Regex("^[\d]{2}$")
thanks :thumb:
Re: [RESOLVED] Text validation help
Hey,
You might want to think about using the built in controls for this, i.e:
http://msdn.microsoft.com/en-us/library/bwd43d0x.aspx
That way you will get validation both on the client side, and the server side.
Gary