changing textbox border colour using javascript changing textbox border colour using javascript javascript javascript

changing textbox border colour using javascript


Use CSS styles with CSS Classes instead

CSS

.error {  border:2px solid red;}

Now in Javascript

document.getElementById("fName").className = document.getElementById("fName").className + " error";  // this adds the error classdocument.getElementById("fName").className = document.getElementById("fName").className.replace(" error", ""); // this removes the error class

The main reason I mention this is suppose you want to change the color of the errored element's border. If you choose your way you will may need to modify many places in code. If you choose my way you can simply edit the style sheet.


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


You may try

document.getElementById('name').style.borderColor='#e52213';document.getElementById('name').style.border='solid';