0

像往常一样,我设置表单验证的规则,如果它们没有通过,我$this->load->view()会再次使用并加载表单。

在 Firefox 和 Opera 上一切正常。但是在所有其他浏览器中,当表单验证没有通过并且再次加载表单时,文档会被格式化。我使用 HTML Tidy 来检查我是否错过了结束标签或其他东西,但一切都很好。

我还使用 W3C HTML5 Validator 检查了源代码。文件通过,没有错误。然后,我运行了表单验证并再次检查了相同的源代码。这次验证器出现了 5 个错误。

 Line 2, Column 1: Non-space characters found without seeing a doctype first. Expected <!DOCTYPE html>.
<!DOCTYPE html>

 Line 2, Column 1: Element head is missing a required instance of child element title.
<!DOCTYPE html>
Content model for element head:
If the document is an iframe srcdoc document or if title information is available from a higher-level protocol: Zero or more elements of metadata content.
Otherwise: One or more elements of metadata content, of which exactly one is a title element.

 Line 2, Column 16: Stray doctype.
<!DOCTYPE html>

 Line 3, Column 19: Stray start tag html.
<html lang="pt-br">

 Line 3, Column 19: Cannot recover after last error. Any further errors will be ignored.
<html lang="pt-br">

<!DOCTYPE html>我知道,在事情变得糟糕之前,当有事情发生时。但我那里没有任何变量。也许 CI 正在产生一些东西。

有没有人可以帮忙?

4

1 回答 1

2

问题是我的应用程序中有两个带有 BOM 文件的 UTF-8。因此,如果表单验证返回 false 并重新加载视图,则在导致这些错误EF BB BF之前将字节集添加到文档的开头。<!DOCTYPE html>所以我将这两个文件保存为没有BOM编码的UTF-8,现在一切正常。

于 2013-04-15T01:51:04.003 回答