为什么一个只有一个
<input>
字段的<form>
在用户输入值并按下Enter时会重新加载表单,而如果<form>
中有2个或更多字段,则不会重新加载? 我写了一个简单页面来测试这个奇怪的问题。如果您在第二个表单中输入一个值并按Enter键,则会看到它重新加载页面,将输入的值作为GET
调用。为什么?我该如何避免这种情况?<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>testFormEnter</title>
</head>
<body>
<form>
<input type="text" name="partid2" id="partid2" />
<input type="text" name="partdesc" id="partdesc" />
</form>
<p>2 field form works fine</p>
<form>
<input type="text" name="partid" id="partid" />
</form>
<p>One field form reloads page when you press the Enter key why</p>
</body>
</html>