In an asp.net page/webform, lets say I have 2 textboxes (for the user to enter a username & password), and 1 cmdOk command button.
What I want to do is check the 2 textboxes & see if they have values in & aren't blank, with a client-side javascript function - something like:
With the same button, I also want to go back to the server & check this login (the username & password entered) against a database. Is there some way I could do both checks from 1 button? i.e. something like:Code:onclick="ValidateTxtBoxes()"
Is this possible please? I don't want the overhead of a round trip to the server if the users just left one of the boxes blank...Code:// Javascript Code called from the onclick event of the button as above function ValidateTxtBoxes() { if ( //User has left one of the boxes blank) { //show them an error message label or alert box //the page never goes back to the server & client side evaluation is performed } else { Call MyWebForm.VBCodePart.Function1() //call some vb code in the codebehind window of the asp.net webform //the page is sent back to the server & data is evaluated against a database } }
Thanks everyone!![]()


Reply With Quote