我负责的一个可怕的问题,我开发了集多领域的形式更多的字段(正常使用DIV) ,当我测试提交操作我在URL中的一个输入不填充了,也隐藏在 的标记中,如下图所示。HTML表单submiting比预期
http://127.0.0.1:8000/exform.html?user=test&pwd=QWERT1234&user_reg=
这里是表单代码:
<form id="exform">
<div class="fields" id="login">
<div class="txt">
<label for="user"></label>
<input id="user" type="text" name="user"/>
</div>
<div class="txt">
<label for="pwd"</label>
<input id="pwd" type="password" name="pwd" />
</div>
<input type="submit" value="test" id="test"/>
</div>
<div class="fields" id="register">
<div class="txt">
<label for="user_reg"></label>
<input id="user_reg" name="user_reg" type="text"/>
</div>
<div class="txt">
<label for="pwd2"></label>
<input id="pwd2" type="password" />
</div>
<div class="txt">
<label for="pwdc"></label>
<input id="pwdc" type="password"/>
</div>
<div class="buttons">
<input type="submit" value="OK" id="ok"/>
</div>
</div>
</form>
奇怪的是,第二场集不在屏幕可用,因为在CSS 有只有一个规则显示第一组与类“字段”
/*Hide all except first div with class div*/
#exform .fields:not(:first-of-type) {
display: none;
}
所以我真的想知道为什么窗体提交字段超出范围。
例如,如果使用第二组字段集,当按钮与值确定提交被点击所产生的结果是类似的。在URL中,只有user_reg场参数表现出充满了对第一组两个另一场无值:
http://127.0.0.1:8000/exform.html?user=&pwd=&user_reg=test
下面的代码是提交测试:
$(function() {
$('#test').click(function() {
$('#exform').submit(function(event) {
console.log("form Submited:" + document.forms['exform'] + "test");
});
});
$('#ok').click(function() {
$('#exform').submit(function(event) {
console.log("form Submited:" + document.forms['exform'] + "ok");
});
});
});
没关系我得到了相同的URL导致
这
http://127.0.0.1:8000/exform.html?user=test&pwd=QWERT1234&user_reg=
或
http://127.0.0.1:8000/exform.html?user=&pwd=&user_reg=test
相反,我收到:
// on #test click
http://127.0.0.1:8000/exform.html?user=test&pwd=QWERT1234
// on #ok click
http://127.0.0.1:8000/exform.html?user_reg=test&pwd2=QWERT1234&pwdc=QWERT123
为提交后得到的参数,我不能检索的URL pwd2和pwdc字段中的值。
这让我发疯。