I have a form that I would like all fields to be filled in. If a field is clicked into and then not filled out, I would like to display a red background.
(我有一个表格,我希望所有字段都填写。如果一个字段被点击,然后没有填写,我想显示一个红色背景。)
Here is my code:
(这是我的代码:)
$('#apply-form input').blur(function () {
if ($('input:text').is(":empty")) {
$(this).parents('p').addClass('warning');
}
});
It applies the warning class regardless of the field being filled in or not.
(无论填写的字段是否填写,它都会应用警告类。)
What am I doing wrong?
(我究竟做错了什么?)
ask by Keith Donegan translate from so