Flashing Validation

by Borna Almasi

HTML

<input id="txt" type="text" />

<button> Hi </button>

CSS

.red{
    background: #EE8888;
}

JavaScript

function flashfocus(jqElem, count, fast) {
    if (count > 0) {
        jqElem.toggleClass("red");
    window.setTimeout(function() {
        flashfocus(jqElem, count - 1,fast);
    }, fast);
    }
}

$('button').click(function() {
    if (!$('#txt').val()) {
        flashfocus($("#txt"), 6, 100);
    }

});