<form action='index.php' method=post> test<input id="1" type="text" name="pole1" onchange="test(this.id, this.type, this.value)"> </form> <script language='javascript'> function test(id, type, value) { if(document.getElementById(id).value=='xxx') { document.write("Bląd").getElementById(id).style.borderColor='red'; } else { document.getElementById(id).style.borderColor='green'; } } </script>