Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validation problem

Status
Not open for further replies.

James1981

Programmer
Nov 2, 2002
76
US
Hi,

I want to validate two separate textboxes with two separate buttons on the same page but the two different validations effect one another.

I want the user to choose only one textbox to input into and then choose the respective button to click. Is there a way that .NET can differentiate between the two textboxes/buttons and produce the correct javascript validation or will I have to accept a submit and do the validation server side?

Cheers

James
 
James - little unclear as to what you want to do exactly, w.r.t. two buttons and two textboxes.

You want the user to enter data into one of the textboxes then click on the button next to it?

Javascript should work here just not exactly sure what it is that is going on.
 
I have two RequiredFieldValitors each acting on one of the textboxes. However, I can't submit the form unless both textboxes are filled out no matter which submit button i press.

I think you are right that I am going to have to write some custom javascript validation.

Sorry about being unclear.

James
 
Good point James. Yes, if you have two textboxes calling for validation (Validators inherently use javascript in dot NET so are client side) then one will flag if no value is added to the other. You might have to use server side validation and vb code to handle this - but there surely must be a javascript solution to this. We'll see if someone has a specific solution - will look at this further and get back with you.
 
I suggest going the server validate route. Yes, there is always a javascript solution, but they break quite easily when anything on the page changes due to the fact that ASP.NET loves to change those id's on you.

Server validation is quick, easy, and more solid than any javascript solution you could come up with. Additionally, you'll have much less time invested in maintaining a server side validation routine. That's my biggest plus for it.

And as for the argument, "I don't want my users to have to wait for a round trip to the server". My response to that is, "Well, if the users fill the form out correctly the first time, then it won't matter, will it?"

So, in essence, it's their own fault. Let them wait an extra .237 seconds. It won't kill them.

:)
paul
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
Paul: good point re: ASP.NET ID changes. And your right, an extra .237 seconds for not following directions is something one can live with. Even on slow internet connections a round trip is less than a second in most cases.
 
Thanks guys!

It's well documented that programmers hate users - i think this a prime example! To hell with the stupid ones, eh? :)

Cheers
James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top