changing textbox border colour using javascript

后端 未结 7 563
心在旅途
心在旅途 2020-12-30 02:20

I\'m doing form validation. when the form input is incorrect i add a red border to the textbox:

document.getElementById(\"fName\").style.borderColor=\"#FF000         


        
7条回答
  •  伪装坚强ぢ
    2020-12-30 03:07

    I'm agree with Vicente Plata you should try using jQuery IMHO is the best javascript library. You can create a class in your CSS file and just do the following with jquery:

    $('#fName').addClass('name_of_the_class'); 
    

    and that's all, and of course you won't be worried about incompatibility of the browsers, that's jquery's team problem :D LOL

提交回复
热议问题