如何排除在提交表单的某些表单字段没有禁用领域 [英] How do I exclude certain form fields upon submission of the form without disabling the field

查看:94
本文介绍了如何排除在提交表单的某些表单字段没有禁用领域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有以下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.

这篇关于如何排除在提交表单的某些表单字段没有禁用领域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆