如何排除在提交表单的某些表单字段没有禁用领域

问题描述:

如果我有以下3个字段的表单:

If I have a form with the following 3 fields:

姓名出生日期

当用户填写了所有3个领域,并提交你会得到URL

When the user fills in all 3 fields and submits you will get the URL

http: //fakeURL.php?firstName=Fred&lastName=Flintstone&DateOfBirth=2/5/1952

然而,如果用户只填充在名字和出生日期,你会得到

However, if the user only fills in First Name and Date Of Birth you will get

http: //fakeURL.php?firstName=Fred&lastName=&DateOfBirth=2/5/1952 (where lastName has no value)

我如何实现

http: //fakeURL.php?firstName=Fred&DateOfBirth=2/5/1952 (where lastName and value are removed from the URL)

我不希望在使用的onsubmit禁用输入字段。有没有更好的办法不是禁止输入字段?

I don't want to disable the input field upon using onsubmit. Is there a better way than disabled the input field?

请帮忙...

您必须:

  1. 删除或提交之前,禁止从表单字段
  2. 请不要提交表单,而不是重定向到你自己
  3. 的形式构造一个URL
  4. 请离开页面的AJAX请求,而不是
  1. Remove or disable the field from the form before submitting it
  2. Don't submit the form, instead redirect to a URL you construct from the form yourself
  3. Make an AJAX request instead of leaving the page

除了这些选项,则无法通过GET不会全部成为URL的一部分输入提交此表。这就是在HTML和HTTP规范的一部分。

Aside from those options, you can't submit this form via GET without all the inputs becoming part of the URL. That's part of the HTML and HTTP specifications.