hebiao

html显示乱码

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script>
function validateForm() {
    var x = document.forms["myForm"]["fname"].value;
    if (x == null || x == "") {
        alert("需要输入名字。");
        return false;
    }
}
</script>
</head>
<body>

<form name="myForm" action="demo_form.php"
onsubmit="return validateForm()" method="post">
名字: <input type="text" name="fname">
<input type="submit" value="提交">
</form>

</body>
</html>

显示乱码,名字跟提交

原因是<meta charset="utf-8" />没有生效,这种写法是html5特性,需要

http-equiv="Content-Typecontent="text/html; charset=UTF-8"

分类:

技术点:

相关文章:

  • 2021-09-12
  • 2021-11-11
  • 2021-08-05
  • 2021-11-01
  • 2021-09-19
  • 2022-12-23
  • 2021-09-19
  • 2021-09-19
猜你喜欢
  • 2021-10-18
  • 2021-09-01
  • 2021-11-01
  • 2022-01-01
  • 2021-11-13
  • 2021-11-05
相关资源
相似解决方案