Reputation: 1919
the border color will be depending on the current typed value. I've tried to change the className of the input text using javascript when onkeypress event happens,
element.className= 'recordInputEdited';
however, it cannot get rid of the :focus style, the new class is visible until the text box loses focus. any idea?
Upvotes: 0
Views: 2372
Reputation: 6908
This should work: http://jsfiddle.net/GQSsw/
HTML:
<input id="element" />
Javascript:
document.getElementById('element').onkeydown = function() {
this.className= 'edited';
}
CSS:
input {
border: 1px solid red;
}
input:focus {
border: 1px solid green;
}
input.edited {
border: 1px solid yellow;
}
Upvotes: 1