开发者

"back" form button giving XHTML erros

开发者 https://www.devze.com 2023-01-28 00:49 出处:网络
I am trying to validate my pages with \"back\" form buttons and I keep receiving the below errors. I\'m not sure开发者_Go百科 what I\'m doing wrong or how to fix it.

I am trying to validate my pages with "back" form buttons and I keep receiving the below errors. I'm not sure开发者_Go百科 what I'm doing wrong or how to fix it.

Errors:

Line 54, Column 10: required attribute "action" not specified

Line 56, Column 54: there is no attribute "onClick" …type="button" value="Go Back" onClick="history.go(-1);return true;" alt="Go Ba…

Line 56, Column 98: end tag for "input" omitted, but OMITTAG NO was specified …="button" value="Go Back" onClick="history.go(-1);return true;" alt="Go Back">

Line 56, Column 9: start tag was here


Line 54, Column 10: required attribute "action" not specified

Forms need an action, the attribute specifies a URL to submit the form data to.

In this case, it sounds like you don't have a form, just a button with some JavaScript hooked up to it. Get rid of the form element.

Line 56, Column 54: there is no attribute "onClick" …type="button" value="Go Back" onClick="history.go(-1);return true;" alt="Go Ba…

XHTML is case sensitive. All attribute values must be lower case. i.e. onclick

That said, using intrinsic event attributes is considered a bad practice. Aim to use unobtrusive JavaScript (i.e. start with HTML elements which make sense without JavaScript (and generate the entire element with JS when that is impossible) and bind events using JS. Then put all the JS in an external file and reference it with a src attribute).

Line 56, Column 98: end tag for "input" omitted, but OMITTAG NO was specified …="button" value="Go Back" onClick="history.go(-1);return true;" alt="Go Back">

All elements require end tags. e.g. <input></input>, except that input is defined as an empty element and you are almost certainly serving it with a text/html content-type, so you need to use the empty element syntax and end the start tag with a slash instead of having an explicit end tag. i.e. <input />

As a final note: Browsers have a back button. Duplicating it is a waste of time and causes confusion as some sites use Back to mean "Forward to where we expect you came here from" and others mean "Use JavaScript to emulate clicking on the browser's back button". The two different meanings sometimes mean that users don't know where the button will actually go, and won't know what effect it will have on their browser history (i.e. how their back and forward buttons will act).


Line 54, Column 10: required attribute "action" not specified

<form> tags require an action attribute, like <form action="/some/path">

Line 56, Column 54: there is no attribute "onClick" …type="button" value="Go Back" onClick="history.go(-1);return true;" alt="Go Ba…

All attributes must be in lowercase, like onclick="whatever"

Line 56, Column 98: end tag for "input" omitted, but OMITTAG NO was specified …="button"

All tags must be closed, so change your input to include a closing /, like this: <input type="button" ... alt="Go Back" />

Line 56, Column 9: start tag was here

This is just pointing to where the unclosed tag above started.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号