I made a condition that is not respecting the contents of text
. Home
Here is the code:
function teste() {
var elements = document.getElementsByClassName("testetxt");
if (elements.value =! null) {
elements.style.border = 'solid 1px #00FF00;';
alert("Ok");
} else if (elements.value == null){
elements.style.border = 'solid 1px #FF0000;';
alert("Preencha o campo Código");
}
}
<html>
<body>
<input class="testetxt" type="text"/>
<button onclick="teste();" style="height:20px; width:20px;"> </button>
</body>
</html