1
votes

we are useing IBM rational policy test to scan our codes and it is giving us a defect on the username and password, asking for a label with for attribute, is there a way to add a label with for and the label wont show on the screen? if i use empty label, the software still giving me a defect again but the different message

Sign In
        <input class="user-name" placeholder="Username" type="text" id="username" name="username"></input>
        <input class="password" placeholder="Password" type="password" id="password" name="password"></input>
        <input type="checkbox" id="chkRememberMe" name="chkRememberMe"></input>

and this is the message which i get from the software: Each form control should have associated text Associate text with each FORM control that is not of type "hidden". INPUT controls of type "submit", "reset", and "button" require text to be set in the "value" attribute. INPUT controls of type "image" require text to be set in the "alt" attribute. All other FORM controls are associated with text via the LABEL element. A LABEL is attached to a specific form control through the use of the "for" attribute. The value of the "for" attribute must be the same as the value of the "id" attribute of the form control.

1

1 Answers

0
votes

Simply adding them and hiding them via CSS should do what you need --

<label for="username">Username</label>
<label for="password">Password</label>

and in CSS:

label {display:none;}

Do note though, that it is generally better to have labels associated with your items that are visible - it makes it much easier for accessibility as well.