• Register
0 votes
317 views

Problem :

Facing following strange error
the value of the for attribute of the label element must be the id of a non-hidden form control.
6 5 3
6,930 points

Please log in or register to answer this question.

2 Answers

0 votes

Solution :

The label for attribute should have the input id value as shown below

<label for="foo">Foo:</label>
<input id="foo">

Now to omit the for and id attributes completely, please put input inside label as shown below

<label>
    Foo: <input name="foo">
</label>

Also please note input cannot be hidden like <input type="hidden"> but  it can be styled as hidden <input style="display:none">

If you follow above approach then your issue will be resolved.

9 7 4
38,600 points
0 votes

Solution:

The label for attribute must contain the input id value

<label for="foo">Foo:</label>
<input id="foo">

To omit the for and id attributes all-together, put input inside label

<label>
    Foo: <input name="foo">
</label>

Also note, that input cannot be hidden <input type="hidden">, however it can be styled as hidden <input style="display:none">

If you use the for attribute in a label element it has to match the id of an input element in your form

<label for="field-id" style="line-height:24px;">Your Name</label><br>&nbsp;&nbsp;
<input type="text" id="field-id">

The for attribute of a <label> must refer to the id attribute of a form input.

Use:

<label for="email-field">Email</label>
<input name="email" id="email-field" type="text" />

instead of:

<label for="email-field">Email</label>
<input name="email" id="email" type="text" />

 

10 6 4
31,120 points

Related questions

0 votes
2 answers 92 views
92 views
Problem : I want to know why I keep facing below error while I try to check my page on http://validator.w3.org/check The error is as below : Line 300, Column 90: The for attribute of the label element must refer to a form control. <label for="myname" style ... ;&nbsp;  <input class="css_form_namefield TooltipIstok " type="text" name="myname" value="" style="width: 600px;" maxlength="60" > </div>
asked Jan 3, 2020 alecxe 7.5k points
0 votes
1 answer 509 views
509 views
Problem : I was hoping that someone may know how to resolve the below HTML5 validation error. When I try to validate my page it gives me a below error : Error Line 90, Column 63: An body start tag seen but an element of the same type was already open. <body class=" ... only find the one <body> (the one referenced by above error) and one </body>. Can anyone please tell me how to fix above error?
asked Jan 25, 2020 jwilliam 3.9k points
1 vote
1 answer 743 views
743 views
Problem : I am very new to Angular 4. Please find below my component in Angular 4: @Component( { selector: 'input-extra-field', template: ` <div class="form-group" [formGroup]="formGroup" > <switch [attr.title]="field.etiquette" [attr.value]="field.valeur" ... .../../../forms/@angular/forms.es5.js.FormControlDirective.ngOnChanges (forms.es5.js:4617) Please guide me in fixing above Angular 4 error.
asked May 11, 2020 stewart 4k points
0 votes
1 answer 51 views
51 views
Problem : I am facing below error if I try to export datagrid to the excel. &ldquo;Control 'gridview1' of type 'gridview' must be placed inside a form tag with runat=server.&rdquo; Please find below my code : <form runat="server" id="form1"> <div runat="server" id=" ... TextBox> </form> My GridView is within the from tag with the runat="server", but still I am facing above error. How to fix this?
asked Feb 17, 2020 mphil 2.3k points
0 votes
1 answer 2.7K views
2.7K views
Problem : I am facing following error from the Angular 2 core.umd.js:5995 EXCEPTION: Uncaught (in promise): Error: Error in app/model_exposure_currencies/model_exposure_currencies.component.html:57:18 caused by: If ngModel is used within a form tag, either the name attribute must be set or the form ... 0-9]+)?" required> </div> </td> Below is my form tag: <form #f="ngForm" (ngSubmit)="onSubmit()">
asked Dec 3, 2019 alecxe 7.5k points
0 votes
1 answer 1K views
1K views
Problem : I am much more familiar with the enums in C# but it seems like enums in the Java is a quite different. Currently I am trying to use the switch statement @ enums in my below code but I always face the below error no matter what I am doing. The error I ... myenumExample //... switch (myenumExample) { case MyAnotherClass.MyEnum.MYVALUE_A: { <-- facing error on this line //.. break; } } } }
asked Dec 25, 2019 alecxe 7.5k points
0 votes
1 answer 49 views
49 views
Problem : I have written two different types of sticky menus for two different pages. Following is the error Inside the anonymous function, use jquery to select the footer div. it has an id of 'footer'. Following is the code for both Menus. $(document).ready(function () { ... the bottom doesn't work because the second line of code var contentNav = $('.content-nav').offset().top; fires a error .
asked Nov 19, 2019 peterlaw 6.9k points
1 vote
1 answer 138 views
138 views
Problem : I am very new to Paypal. I am trying to use the plugins to set up my website. Currently I have started testing my site in the Sandbox mode but I am facing the following error after completing a Paypal process: &ldquo;Validation error: PayPal IPN response ... I have tried to fix above error but it still appears. Can someone who had faced this issue earlier guide me in fixing above error?
asked Apr 4, 2020 morrisBson 3.2k points
0 votes
1 answer 274 views
274 views
Problem : Currently I am trying to learn the Apache Maven. I have tried to write below code in Eclipse but it is giving below error to me: Error Message: &ldquo;No grammar constraints (DTD or XML Schema) referenced in the document&rdquo; My Code : <project xmlns="http:// ... > <version>3.0</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins>
asked Feb 27, 2020 mphil 2.3k points
0 votes
1 answer 27 views
27 views
Problem: Can anyone help it was actually asked in exam as following and I need to know whether my answer was right or not? When coding an audio element, the code placed before the closing audio tag is considered to be: Question options: invalid fallback content only available to browsers that support HTML5 required
asked Feb 21, 2020 maddi86 5.4k points