how to validate mulitple text boxes when user enters value in any one of the text box he can submit the form

I have multiple textboxes which im using for search query ,i want to validate them in such a way that if any one text box has value user can submit.

Can anyone suggest me ,how to do it .

Thanks

Answers


On your click event for the submit button, include some if/then statements that check all of the textboxes to see if they have acceptable values. If you just want to be sure that at least one box has data entered in it, then you could do this:

if (textBox1.Text != "" || textBox2.Text != "" || ...)
{
    // process form submission
}
else
{
    // inform user of missing data
}

If you are doing this client-side, in the web application, your best method will be to use JavaScript to perform the validation when the submit button is clicked. Otherwise the user will have to wait for the server to check the variables and get a new page.


Need Your Help

Launching a new command window from Golang in Windows

windows go

I'm writing a go application that just uses the command window (CMD) for user input and output. I need to launch another instance of the application that is using its own window.