Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3406790
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:40:16+00:00 2026-05-18T05:40:16+00:00

I have written a set of functions to validate the textboxes in my form

  • 0

I have written a set of functions to validate the textboxes in my form for their required field needs like this

private void ValidateForm()

        {
        //Initialise the variables for validation check and call the related functions
        bool bisValidhost = ValidateHost();
        bool bisValidPassword = ValidatePassword();
        bool bisUsername = ValidateUsername();

        //If any of the entries is missing then show error message
        if(bisValidhost && bisValidPassword && bisUsername == false)
            {
            MessageBox.Show("This is not a Valid Entry!");                
            }         
        }


    /// <summary>
    /// This function validate the Required field need of txtHost.
    /// </summary>
    /// <returns></returns>
    private bool ValidateHost()
        {
        ErrorProvider errorProvider = new ErrorProvider();
        bool isValid = true;

        //If the txtHost is empty, show a message to user
        if(txtHost.Text == string.Empty)
            {
            errorProvider.SetError(txtHost, "Please enter the host address");
            isValid = false;
            }
        else
            errorProvider.SetError(txtHost, string.Empty);
        return isValid;
        }


    ///<summary>
    /// This function validate the Required field need of txtUsername.
    /// </summary>
    /// <returns></returns>
    /// </summary>
    /// <returns></returns>
    private bool ValidateUsername()
        {
        ErrorProvider errorProvider = new ErrorProvider();
        bool isValid = true;

        //If the txtUsername is empty, show a message to user
        if(txtUsername.Text == string.Empty)
            {
            errorProvider.SetError(txtUsername, "Please enter the Username");
            isValid = false;
            }
        else
            errorProvider.SetError(txtUsername, string.Empty);
        return isValid;
        }


    ///<summary>
    /// This function validate the Required field need of txtPassword.
    /// </summary>
    /// <returns></returns>
    /// </summary>
    /// <returns></returns>
    private bool ValidatePassword()
        {
        ErrorProvider errorProvider = new ErrorProvider();
        bool isValid = true;

        //If the txtPassword is empty, show a message to user
        if(txtPassword.Text == string.Empty)
            {
            errorProvider.SetError(txtPassword, "Please enter the Password");
            isValid = false;
            }
        else
            errorProvider.SetError(txtPassword, string.Empty);
        return isValid;
        }

But it is not displaying the proper messages.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T05:40:17+00:00Added an answer on May 18, 2026 at 5:40 am

    I may be mis-interpreting your IF construct of

    if(bisValidhost && bisValidPassword && bisUsername == false) 
    

    but I think you want

    if( ! ( bisValidhost && bisValidPassword && bisUsername ))
    

    Lets say your answers were all TRUE (ie: valid), then its interpreting it as

    if ( TRUE and TRUE and ( TRUE == FALSE ))
    

    If one of the first two was FALSE and the last was ok, you would have

    IF ( FALSE AND FALSE AND ( TRUE == FALSE))
    

    by doing the logical NOT (!) and checking if any one of them fail is what you want.

    if NOT ( all 3 parts valid )

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a set of javascript functions that allow me to validate user
I have written a set of Matlab functions and I want to distribute it
The functions I have written are throwing exceptions if they can't do their job.
I have written a set of classes and interfaces that are implemented in Moose
I have written the following regex to match a set of e-mails from HTML
I have written a method to calculate a given percentile for a set of
I have a login page written in classic asp. I want to set the
have written this little class, which generates a UUID every time an object of
I have written this code inside a servlet to delete certain records from three
I have written this code in JavaScript and works perfectly fine when I include

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.