validation control

M

Mike

I have a web form that has 2 buttons and a textbox and a listbox. I need to
validate each control but only if the buttons assocaited with that control
is clicked.

example:
textbox1 = need to validated if the 'add' button is clicked

I then have a listbox that i need validated to make sure something is
selected but only when the
'submit' button is clicked.

right now the 'add' button is firing both validators? How can I fire each on
seperatly for each button?
 
B

Brandon Gano

You could set up Click event handlers for the buttons that enable/disable
the validators as necessary. I'm not sure how this would work within the
event cycle. You may have to mess around a bit to get it working.

// Pseudo code
OnAddClick
{
Disable SubmitValidator
Enable AddValidator
}
OnSubmitClick
{
Disable AddValidator
Enable SubmitValidator
}

To make your interface more humane, you will probably want to try to run the
"Add" code as well. Otherwise, data may be lost if they enter the last item
and click "Submit" instead of "Add".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,709
Latest member
AustinMudi

Latest Threads

Top