Показать сообщение отдельно
  #2 (permalink)  
Старый 10.02.2013, 13:47
Аватар для danik.js
Профессор
Отправить личное сообщение для danik.js Посмотреть профиль Найти все сообщения от danik.js
 
Регистрация: 11.09.2010
Сообщений: 8,804

<input id="color" style="font-family:monospace" />
<script>
    color.oninput = function(e) {
        var input = this.value;
        if (/^[0-9a-f]{6}$/.test(input)) {
            this.style.backgroundColor = '#' + input;
            this.style.borderColor = '';
        } else {
            this.style.borderColor = 'red';
            this.style.backgroundColor = '';
        }
    }
</script>


Правда не принимает трехсимвольный код
Ответить с цитированием