Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post

    HTML Validator 'warning'

    Hello

    I am getting the following HTML 'warning' about this line:

    Code:
    <input type="hidden" name="Action" value="SendEmail">
    The explanation for the warning is that
    The value of the "name" attribute ("Action") may conflict with properties of the JavaScript Form object when using JavaScript.
    It is then recommended that I change this: name="Action"

    The page doesn't actually use any JavaScript, so does it matter? Will it flag up with the search engines and, if so, what would I change it to?

    The page itself it here:

    http://www.bayingwolf.com/contact.asp

    Many thanks

    Steve

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,092
    Thanks
    23
    Thanked 594 Times in 593 Posts
    I say appease the grammar gods, the error gods, any god that doesn't cost you money.
    So, would it break your heart to use name="mail_action" or not use the name attribute at all? It will stop the protesting and to me that's a good thing.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • Users who have thanked sunfighter for this post:

    SteveH (02-02-2014)

  • #3
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,300
    Thanks
    28
    Thanked 275 Times in 269 Posts
    Quote Originally Posted by SteveH View Post
    The page doesn't actually use any JavaScript, so does it matter?
    The warning isn't applicable to your document. It's talking about cases like the following where a form control element has a name="action" attribute:

    Code:
    <form id="myForm" action="http://example.com/">
    	<input type="text" name="action">
    </form>
    <script>
    	var form = document.getElementById("myForm");
    	console.log(form.action); // HTMLInputElement
    	form.removeChild(form.action);
    	console.log(form.action); // http://example.com/
    </script>
    In that case, the action property refers to the input element when it would normally refer to the action attribute of the form element.

    In your case, there would never be a conflict because property names are case-sensitive and Action isn't a case-sensitive match for action. It would also be a moot point if you don't need the value of the action attribute or aren't using JavaScript.

    Quote Originally Posted by sunfighter View Post
    I say appease the grammar gods, the error gods, any god that doesn't cost you money.
    I say ignore them all and eat the apple of knowledge.
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • Users who have thanked Arbitrator for this post:

    SteveH (02-02-2014)

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,620
    Thanks
    0
    Thanked 645 Times in 635 Posts
    Quote Originally Posted by Arbitrator View Post
    I say ignore them all and eat the apple of knowledge.
    I disagree. The warning is there because if the code gets changed in the future that name could potentially cause a problem.

    It is far simpler to simply change the name to something else so as to avoid even the possibility of a conflict. After all there are trillions of other possible names that can be used that will not give that warning.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • Users who have thanked felgall for this post:

    SteveH (02-02-2014)

  • #5
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    I used Mail_Action (hehehehe).

    Many thanks to all!

    Steve

  • #6
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,300
    Thanks
    28
    Thanked 275 Times in 269 Posts
    Quote Originally Posted by felgall View Post
    I disagree. The warning is there because if the code gets changed in the future that name could potentially cause a problem.
    "Potentially" without concrete details. As far as I can tell, such a conflict will never occur in reality. (I seem to recall having a similar conversation with you a few threads back over the target attribute where no concrete justification could be provided regarding vague claims of issues in "many browsers".)

    Anyway, I was going to file a bug report to get the warning removed, but then I realized that this error message isn't originating from the W3C validation website, but the CSE HTML Validator program. The full warning message is "The value of the "name" attribute ("Action") may conflict with properties of the JavaScript Form object when using JavaScript. It is recommended that the value of the "name" attribute be changed to avoid potential conflict when accessing the form object's properties, methods, and event handlers. Values that should not be used include "action", "elements", "encoding", "length", "method", "name", "target", "reset", "submit", and some others." Again, there's no reason to believe this is true.

    I considered signing up on the CSE HTML Validator forum to ask them to fix it, but decided against bothering after I noticed other bogus warnings and because I don't use the program in question. For example, for the code <button>Submit</button>, it throws two warnings: "This form does not appear to contain a submit control so that the form data can be submitted in the normal way. Consider using an "input" element with type="submit" or type="image" or a "button" element with type="submit"." and "The "button" tag has no attributes. Attributes are normally used with this element." There is some justification behind these at least, although the warnings themselves are wrong and would also warrant a bug report. (They should actually be one message reading "Bugs in the (obsolete) browsers MSIE6 and WIE7 require that type="submit" be explicitly specified on button elements intended for form submission.")
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #7
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,629
    Thanks
    6
    Thanked 1,002 Times in 975 Posts
    Hmm, I myself was under the impression that a button element without type attribute does nothing by itself, and in order to have it submit, the type must be set to “submit”?

  • #8
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,620
    Thanks
    0
    Thanked 645 Times in 635 Posts
    Quote Originally Posted by VIPStephan View Post
    Hmm, I myself was under the impression that a button element without type attribute does nothing by itself, and in order to have it submit, the type must be set to “submit”?
    A button element without a type specified gets the default of type=:submit"
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #9
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,620
    Thanks
    0
    Thanked 645 Times in 635 Posts
    Quote Originally Posted by Arbitrator View Post
    "Potentially" without concrete details.
    Even if the potential problem is that the code is harder to maintain because you lose track of what certain words refer to that is a good enough reason to avoid it.

    Keeping your naming obviously different from all the names used within the languages you are using will save you a lot of time maintaining the code.

    Obviously you have only ever worked on small projects or you wouldn't be taking the viewpoint that you have.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #10
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,300
    Thanks
    28
    Thanked 275 Times in 269 Posts
    Quote Originally Posted by VIPStephan View Post
    Hmm, I myself was under the impression that a button element without type attribute does nothing by itself, and in order to have it submit, the type must be set to “submit”?
    As felgall already indicated, the "Submit Button state" is the default. This is true in both HTML4 and HTML5, so it isn't anything new. The confusion isn't surprising though; I was thinking HTML5 might have changed things from HTML4 and looked things up before I made that post:

    http://www.whatwg.org/specs/web-apps...button-element
    http://www.w3.org/TR/html401/interac...ml#edef-BUTTON

    Quote Originally Posted by felgall View Post
    Even if the potential problem is that the code is harder to maintain because you lose track of what certain words refer to that is a good enough reason to avoid it.
    I suppose it's a moot point; the name used now (Mail_Action) is certainly better than the previous name in terms of descriptiveness.

    I still think that changing the name just because of undescribed "potential problems" and in the absence of another issue is unjustified though. form.getElementsByName("Action").item(0) isn't particularly confusing, IMO. http://example.com?Action=SendEmail isn't either. (I'd be more concerned about the URL capitalization.) But I guess it would be somewhat confusing if your large projects have coders writing hard-to-read code that uses name-to-property getters like form.Action.
    For every complex problem, there is an answer that is clear, simple, and wrong.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •