Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.