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

后端 未结 7 1568
遇见更好的自我
遇见更好的自我 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条回答
  •  旧时难觅i
    2020-12-03 01:05

    $field = $("#sender_container input.required");
    if( ! $field.val())
    {
        $field.addClass("error");
    }
    

    this simple way may work.

提交回复
热议问题