|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
javascript to change element class
This should be simple. If a form field doesn't validate, I want to turn the label for that field red and give a pop-up. To color the text, I've used the SetAttribute method to set the class to one declared as having red text in my CSS.
Works like a charm in Firefox (of course), but not in IE. Can anyone point me in the direction of WHY it doesn't work in IE? The JavaScript function checkZip(fld) { var val=fld.value; var Dgts=val.match(/d/g); if(Dgts==null || (Dgts.length!=5 && Dgts.length!=9 )) { alert("The zip code you entered is invalid."); fld.setAttribute('class','textRed'); } else { fld.setAttribute('class','textBlack'); } } The CSS: .textRed { color:red; } Any pointers would be a big help. This crap is making me nuts. Thanks, Ursus |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > javascript to change element class |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|