How to select empty inputs (value=“”) using jQuery

后端 未结 7 1551
遇见更好的自我
遇见更好的自我 2020-12-03 00:31

How can I check for empty values of (required) input fields within a section, and then add a class to them on an event, using jQuery? So far, I have tried:

7条回答
  •  一向
    一向 (楼主)
    2020-12-03 00:58

    to get all fields inspected this might help.

    $('#sender_container [required]').each(function(index)
    {
           if (!($(this).val())) $(this).addClass('error');
    }
    
    });
    

提交回复
热议问题