The easiest in this case is really to use jQuery. This way you can use a generic selector and apply the validation on all items.
$("#price*").each(function() {//Do your validation here $(this) is the item price, then price2 then price3})
For anything else you would need to query the DOM and then that doesn't work the same in all browsers.
Today, you can't really do anything in Javascript and ignore something like jQuery http://docs.jquery.com/ or Scriptalicious.