AngularJS / JQuery - 没有关联标签的表单输入

AngularJS / JQuery - form input without an associated label

我对 "Form input without an associated label" 有疑问。这出现在 [textarea]、[select]、[select]、[input] 类.

这是我的代码:

<div class="panel-body">
<form name="f" data-ng-submit="addTodo()">
  Nazwa:
  <textarea class="form-control" name="newTodo" data-ng-model="formData.newTodo" required></textarea>
  Typ:
  <select class="form-control" name="type" data-ng-model="formData.type" data-ng-option="value.name for value in categories" required></select>
  Estymowany czas:
  <select class="form-control" name="estimates" data-ng-model="formData.estimates" data-ng-option="value + 'h' for value in [] | rangeTime:9:true" required></select>
  Data:
  <input class="form-control" type="text" data-ng-model="formData.date" data-ng-data-picker="" name="date" required readonly="readonly">
  <br />
  <button class="btn btn-success" data-ng-disabled="f.$invalid">Add <span class="glyphicon glyphicon-ok"></span></button>
</form>

感谢帮助!

Moderator Clarification: The quoted message stated above is a warning provided by JetBrains products within the IDE. The OP is most likely using either WebStorm or IntelliJ for front-end development.

这不是错误,但是为了用户体验方便,建议将标签与相应的表单元素相关联。例如对于名称字段:

<label for="name">Nazwa:</label>
<textarea class="form-control" id="name" name="newTodo" data-ng-model="formData.newTodo" required></textarea>

我假设您的 IDE 足够聪明,可以识别缺失的标签并为您提供添加这些标签的合理建议。

我猜WebStorm

只需按照建议添加标签即可。 labelradiocheckbox 特别有用,您只需单击标签即可激活它们。