[jQuery] Re: Looking for some help converting this to jquery

2009-07-23 Thread RobG
On Jul 24, 3:20 am, sleepwalker wrote: > Eric you rock that's what I'm talking about!! Beautiful code man > thanks so much. > Learning is fun. Don't confuse less with better, it is often slower to execute and harder to maintain. The code I posted could be written as: function setButtonClass(

[jQuery] Re: Looking for some help converting this to jquery

2009-07-23 Thread sleepwalker
Eric you rock that's what I'm talking about!! Beautiful code man thanks so much. Learning is fun. Daniel

[jQuery] Re: Looking for some help converting this to jquery

2009-07-23 Thread Eric Garside
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' : '')) ); }) }

[jQuery] Re: Looking for some help converting this to jquery

2009-07-23 Thread sleepwalker
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 ne

[jQuery] Re: Looking for some help converting this to jquery

2009-07-22 Thread RobG
On Jul 23, 6:42 am, sleepwalker wrote: > Hi, > I have a old script that adds a class to a button/submit/reset based > on the length of its value and I'd like to convert it to jquery. I'm > just looking for any suggestions on the best way to rewrite it. Instead of code, can you provide a concis