1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

checked="checked" Not Allowed

Discussion in 'XenForo Questions and Support' started by ibaker, Oct 25, 2012.

  1. ibaker

    ibaker Well-Known Member

    In the process of cleaning up some loose ends on my site and when I validated it I came up with an error for checked="checked"

    I use it to have the remember me check box ticked for all users so in the login-bar-form template I have hidden the check box and made it default checked:
    Code:
    <input type="hidden" name="remember" value="1" id="ctrl_remember" tabindex="103" checked="checked" />
    However when I validate the error says:
    Attribute checked not allowed on element input at this point.

    Can anyone advise how to fix?

    As a side note I am finding a lot of small errors in the validation of the core templates:
     
  2. MagnusB

    MagnusB Well-Known Member

    type="hidden" does not allow checked attribute. AFAIK, you can only have checked on radio and checkbox.
     
    Jake Bunce likes this.
  3. Hoffi

    Hoffi Well-Known Member

    That's correct Magnus.

    Remove tabindex and checked attributes. You did not need a tabindex on a hidden field. ;) And hidden can't be checked.
     
    Jake Bunce likes this.
  4. ibaker

    ibaker Well-Known Member

    Thanks, so how do I make it checked by default and hidden?
     
  5. MagnusB

    MagnusB Well-Known Member

    You need to hide it by CSS, add a class to it, and use display: none;
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Hidden fields just have a value and that's it. Hidden fields are already hidden. And there is no such thing as a "checked" hidden field. It's effectively always checked. The value is always submitted with the form.
     
  7. ibaker

    ibaker Well-Known Member

    So I don't have to set it as "True" or anything, just have this:
    Code:
    <input type="hidden" name="remember" value="1" id="ctrl_remember" />
    Thanks Guys!
     
    Jake Bunce likes this.
  8. Hoffi

    Hoffi Well-Known Member

    Yes. A checkbox return the value, if it's checked. So, this ist no checkbox, the given value will be transferred to the script.

    Just as I said. remove tabindex and checked.
     

Share This Page