最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - AngularJSJQuery - form input without an associated label - Stack Overflow

programmeradmin0浏览0评论

I have a problem with "Form input without an associated label". This appears on [textarea], [select], [select], [input] classes.

Here is my code:

<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>

Thanks for help!

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.

I have a problem with "Form input without an associated label". This appears on [textarea], [select], [select], [input] classes.

Here is my code:

<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>

Thanks for help!

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.

Share Improve this question edited Jun 25, 2015 at 13:19 MegaMatt 23.8k39 gold badges114 silver badges160 bronze badges asked Jun 14, 2015 at 12:21 MordziastyMordziasty 811 silver badge5 bronze badges 4
  • What are you talking about? Where you see that message and when? – user447356 Commented Jun 14, 2015 at 12:24
  • The msg appears while I set the cursor on : <textarea class> <select class> <input class> – Mordziasty Commented Jun 14, 2015 at 12:30
  • You mean in your IDE? If so what IDE? Please give full and correct details, don't have us squeeze the information out of you bit by bit. – user447356 Commented Jun 14, 2015 at 12:35
  • dfsq answered the question. The problem disappeared. – Mordziasty Commented Jun 14, 2015 at 12:40
Add a ment  | 

2 Answers 2

Reset to default 5

This is not an error, however it's remended to associate labels with corresponding form elements for the sake of UX convenience. For example for the name field:

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

I assume your IDE is smart enough to identify missing labels and provide you with a reasonable suggestion to add those.

I guess WebStorm?

just follow the advice and add the label. label is useful especially for radio, checkbox so that you can active them by merely clicking on the label.

发布评论

评论列表(0)

  1. 暂无评论