We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3006
    • 32 Posts
    Ok, so I started to write my own first template and used XHTML - which turned out to be a big no no by all ppl I asked for advice.. So I switched to HTML 4.01 Strict, fine I had to re-write some stuff to make it validate. And you know, the thing with validators is - its like a orgasm everytime you manage it to validate! So when I was playing with AjaxSearch I suddently got alot of new errors in the validator! And I couldn’t make them go away! shocked When I removed two, there were three new!

    One thats been fucking with me is <label for="ajaxSearch_input"> the validator don’t like how its being used...

    What markup are the snippets written for? I hate to rewrite every snippet if they are XHTML and my page is HTML 4.01 Strict.. Shoult I use go back to XHTML and forget the fact that it isnt supported fully in any browser and that it doesn’t do any good if you don’t write it 100% correct?

    Thanks,
    beejay
      • 27708 MODX Staff
      • 2,502 Posts
      AjaxSearch will not validate the way it is written as it is not valid. Period. Edited as I have reviewed the W3C spec and noted that this is a valid method for establishing labeling.

      In order to make it valid you have to change the /assets/snippets/AjaxSearch/inlcudes/templates.inc.php

      The problem is that you cannot have an <input> nested in a <label> as is in the default template.

      Here is what I changed it to (starting around line 18 after ’form’ => ’):

      <form [+as.formId+]action="[+as.formAction+]" method="post">
      			<div><label for="ajaxSearch_input">Search</label>
      							<input id="ajaxSearch_input" type="text" name="search" value="[+as.inputValue+]"[+as.inputOptions+]></div>
      			
      			<div><label for="ajaxSearch_submit"> </label>
      							<input id="ajaxSearch_submit" type="submit" name="sub" value="[+as.submitText+]"></div>
      			
      		</form>
      


      This is still not ideal I still don’t like it as it uses empty elements (<label>) to display results but this will validate in HTML 4.01 or XHTML 1.0 Strict.

      Hope this helps.

      I have also written a plugin that will strip out the end slash in self-closing elements (will post link as soon as I can find it.)

      Cheers,

      Jay
        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
        • 25663 MODX Staff
        • 12,272 Posts
        Some Javascript libraries require valid XHTML doctypes in order to work reliably if that’s important to you at all, including Mootools which drives Ajax Search and Quick Edit. While it can be a bit frustrating getting cross-platform/browser results, I think the benefits of using XHTML layouts far outweigh any drawbacks. I’ve not built an non-XHTML site in more than 3 years.
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 27708 MODX Staff
          • 2,502 Posts
          Ryan you are absolutely right about Javascript Libraries and XHTML.

          Personally, fall into the category of HTML purists who argue that since no browser accepts XHTML as anything other than text/html vs application/xml and all the people who have started using XHTML have done so because someone who built their WYSIWYG editor decided that since XHTML is newer than HTML4.01 we should use it as the default. Unfortunately there are far too many people developing around XHTML and its DOM handlers in the browsers which has meant that I had to swallow my righteous pride and slap on the X every once and a while. 90% of my sites are written using HTML 4.01 and even with some JS libraries as I use so few of the DOM features I don’t need to change. Even though Betamax and Blue Ray were/are better we had VHS and will have HD DVD. Majoruty rules and majority is using XHTML.

          I think that HTML 5 will help bring back the sanity to the world of strict HTML documents.

          BTW, There is nothing wrong with XHTML except it was never intended to replace HTML but to integrate XML application function to the interface.
            Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub