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.
Thanks in advance for any help


function setbuttonclass()
        {
                if(document.getElementById && document.createTextNode)
                        {
                                var x = document.getElementsByTagName('input');
                                for (var i=0;i<x.length;i++)
                                {
                                        var s = x[i].value;
                                        var nolower = s.split(/[^A-Z\W]/);
                                        var word = (nolower.length/2 + 
s.length);

                                if (((x[i].type == 
('button'||'reset'))||(x[i].type == 'reset')||(x
[i].type == 'submit')) && ((word) >= 12)){
                                                 x[i].className = 'mb';
                                                                                
                }
                                else if (((x[i].type == 'button')||(x[i].type 
== 'reset') ||(x
[i].type == 'submit')) && ((word) <= 4) && (word != 0)){
                                                  x[i].className = 'b';
                                                                                
                }
                                else  {
                                                if (((x[i].type == 
'button')||(x[i].type == 'reset') ||(x
[i].type == 'submit')) && (word != 0)){
                                                         x[i].className = 'sb';
                                }
                        }
                }
        }
}

Reply via email to