validation in textbox - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

validation in textbox

NitheeshNitheesh Posts: 7Member
hi,
i have a probs. in validating the date field in vb.net how to write a validation code for a textbox so that it does not accept a character in the date field.


Comments

  • PavlinIIPavlinII Posts: 404Member
    : hi,
    : i have a probs. in validating the date field in vb.net how to write a validation code for a textbox so that it does not accept a character in the date field.
    :
    :
    :
    Hi,
    does not accept characters means what? It can accept onyl numbers? Or it can accept special characters like +-*/#$%^&*( and numbers but not alphabetic characters?

    Do you need this validation during writing expression, or once, when value is finished?

    Your possibilities:
    1) Like operator - for simple conditions..
    Let's say I want only numbers..
    [code]If txtInput.Text Like "*[!0-9]*" Then Msgbox "This is not a number."[/code]

    2) Use regular expressions to validate controls
    System.Text.RegularExpression namespace
    The same situation:
    [code]If Not RegEx.IsMatch(txtInput.Text, "^d*$") Then Msgbox "This is not a number."[/code]



    [blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]

    [purple]Don't take life too seriously anyway you won't escape alive from it![/purple]


Sign In or Register to comment.