From 9f6cbf347ed0a4ae45c23d80ab9cf9f187572daa Mon Sep 17 00:00:00 2001 From: Federico Zivolo Date: Mon, 22 Sep 2014 11:39:24 +0200 Subject: [PATCH] improved detection of empty fields. --- scripts/material.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/material.js b/scripts/material.js index d84fcd04..b9960515 100644 --- a/scripts/material.js +++ b/scripts/material.js @@ -31,14 +31,14 @@ $(function (){ }); $(document).on("keyup change", ".form-control", function() { - if ($(this).val() !== "") { - $(this).removeClass("empty"); - } else { - $(this).addClass("empty"); - } - }); - $(document).on("keydown change", ".form-control", function() { - $(this).removeClass("empty"); + var self = $(this); + setTimeout(function() { + if (self.val() === "") { + self.addClass("empty"); + } else { + self.removeClass("empty"); + } + }, 1); }); $(document) .on("focus", ".form-control-wrapper.fileinput", function() {