changing textbox border colour using javascript

后端 未结 7 617
心在旅途
心在旅途 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 02:41

    If the users enter an incorrect value, apply a 1px red color border to the input field:

    document.getElementById('fName').style.border ="1px solid red";
    

    If the user enters a correct value, remove the border from the input field:

    document.getElementById('fName').style.border ="";
    

提交回复
热议问题