我想检查输入字段是否具有所需的属性。如果这些字段具有空值,并且还具有必需的属性,则在每个字段后附加一个错误 div。在使用选择器时我有点难过
// initialize validator for a bunch of input fields
var inputs = $("#Contact :input")
// Check all required fields
if (inputs.attr("required") && inputs.val() === "") {
var invalidFields = Select all fields that have the attribute required and an empty value, and assign them a class
alert("Required Fields not completed");
}