Simple setup: Shopping Cart in the form of a data list.
Header has two buttons: Update Quantities and Remove Selected Items
Each DataList Item has (among other things) a textbox with the id="txtQty" that stores the quantity of the shopping cart item.
The user should be able to change the values in these textboxes and then hit the Update Quantities button in the header to save all the changes at one time.
I have the logic done for the actual saving, but now I am going back to add some extra validation. I was hoping to call a single JavaScript function from the OnClientClick event of the UpdateQuantities button, which would then iterate through all the DataListItems, find the txtQty textbox, and make sure it is valid numerical input.
I am having a bit of difficulty figuring out the best way of going about this. So far my only real idea would be to loop through the form elements and find anything with an id that matches "txtQty" (since ASP.NET rewrites the id's automatically), and then validating that specific element. This doesn't sound like the best solution. Are there any better ideas floating around out there?