function setButtonClass(){ $(':submit,:reset,:button').each(function(){ var el = $(this), val = el.val(), word = (val.split(/[^A-Z\W]/).length/2) + val.length;
el.addClass( word >= 12 ? 'mb' : (word > 4 ? 'sb' : (word > 0 ? 'b' : '')) ); }) } Untested, but give it a shot. Should work fine, so long as you execute after document.ready. On Jul 23, 12:38 pm, sleepwalker <danielpaulr...@gmail.com> wrote: > Thanks Rob I like your approach and learned a lot. This is why I like > to post code to see how others attack the same issue. I would still > like to see how someone would code this using the jquery syntax rather > then the standard javascript way, so if anyone wants to give it a go > please do. All us newbies learn a lot from this stuff so thanks again. > > Daniel