Adding value attribute to radio buttons and checkboxes

  <legend>what computing devices do you use most?</legend>
  <div
    input type="checkbox" id="phones" name="interest" value= "phones"
    <label value="phones"> Phones</label
  </div
  
  <div>
   < input type="checkbox" id="laptop" name="interest" value= "laptop">
    <label value="laptop"> Laptop</label>
  </div>
  
  <div>
    <input type="checkbox" id="desktop" name="interest" value= "desktop">
    <label value="desktop"> Desktop</label>  
  </div>

this still bring up an error as regards adding value, error message is : " 14. Inside the form element, I can select several fields from a series of checkboxes, each of which must have a value attribute."
please help!!

1 Like

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

1 Like

what error do you get below this failed user story? that should tell you what to fix

also it seems you are missing many < and >, you will need to make sure you have them all in the right place

also, value is not a valid attribute for a label element

<legend>what computing devices do you use most?</legend>
  <div>
  
   <input type="checkbox" id="phones" name="interest" value= "phones"
          <label value="phones"> Phones</label>
</div>
  
  <div>
   <input type="checkbox" id="laptop" name="interest" value= "laptop">
    <label value="laptop"> Laptop</label>
  </div>
  
  <div>
    <input type="checkbox" id="desktop" name="interest" value= "desktop">
    <label value="desktop"> Desktop</label>  
  </div>

This should be the correct syntax

ERROR MESSAGE:
There should be at least 2 checkboxes inside the form : expected 0 to be at least 2
AssertionError: There should be at least 2 checkboxes inside the form : expected 0 to be at least 2
at Proxy.p (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:549:3833)
at Proxy.l (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:431:130)
at Function.n.isAtLeast (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:574:1030)
at a. (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:657:134435)
at https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:598:38668
at i.g.run (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:598:38963)
at N.runTest (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:598:45686)
at https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:598:46651
at o (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:598:45075)
at https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:598:45145

fix the wrong syntax and it should pass, like the missing < and > in the elements around the checkboxes

other possibility is that it doesn’t like that you put them in a div, but first check the syntax

there is also an Analyze HTML tool you can use in codepen to help you in that

1 Like

this is exactly what i have:
i decided to use separate div elements to see if that would fix the value attribute error but it still didn’t work.
but the error is not going away… what am i doing wrong?

<div>
    <input type="checkbox" id="phones" name="interest" value= "phones">
    <label value="phones"> Phones</label>
  </div>
  
  <div>
    <input type="checkbox" id="laptop" name="interest" value= "laptop">
    <label value="laptop"> Laptop</label>
  </div>
  
  <div>
    <input type="checkbox" id="desktop" name="interest" value= "desktop">
    <label value="desktop"> Desktop</label>  
  </div>

share your pen, then

Can you try using “for” attribute in the label tag?

they are not inside the form element

they are at lines 12-26

the form start at line 49

2 Likes

hello sir
the value should be inside the input element and
i.e

< input type="checkbox" id="laptop" name="laptop">
Phones
the label should always be included so that it corresponds to the input ..