jQuery('[max]').change(function() {
var max = parseInt(jQuery(this).attr('max'), 10) || 10000;
var value = parseInt(jQuery(this).val(), 10) || 0;
if (value > max) {
alert('We only have ' + max + ' of this item in stock');
jQuery(this).val(max);
}
});