如果用户输入无法识别的城市,我该怎么办?

发布于 2024-10-16 05:23:39 字数 358 浏览 10 评论 0原文

我正在尝试开发一种供用户输入地址的简单方法。

我已经有了一个邮政编码和城市的数据库,因此如果用户输入他的街道地址和邮政编码,我(通常)可以自动检索城市、省份和国家/地区。但是,如果我的数据库中缺少此信息,他们将需要填写它。

我正在尝试确定它应该是什么样子。我是否应该默认显示 2 个字段(街道和邮政编码),然后在填写完毕后,使用 AJAX 验证邮政编码,如果未找到,则显示其余字段?这样做的缺点是它们可能在表单出现之前就已完成其余部分。

我可以采取相反的方法,仅在找到邮政编码时隐藏额外的字段。但随后他们可能会填写在验证时不需要的信息。或者有一些中间立场吗?

只是想找出人们输入地址的最快、最简单/用户友好的方式。建议?

I'm trying to develop an easy way for users to enter addresses.

I've got a database of postal codes and cities already, so if a user enters his street address and postal code, I can (usually) retrieve the city, province, and country automatically. However, if this information is missing from my database, they'll be required to fill it in.

I'm trying to decide what this should look like. Should I just display the 2 fields (street and postal code) by default, and then after they've filled it out, use AJAX to validate the postal code, and if it's not found, make the rest of the fields appear? This has the drawback that they may be part way through the rest of the form before it appears.

I could take the opposite approach and hide the extra fields only if the postal code is found. But then they might fill out information they didn't need to by the time its validated. Or is there some middle ground?

Just trying to figure out the quickest and easiest/user-friendly way for people to enter addresses. Suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

何时共饮酒 2024-10-23 05:23:39

我以前做过这个。我让用户输入街道和邮政编码,然后他们必须选择他们来自哪个城市,以防有多个城市可供选择。我没有隐藏任何字段,但在通过 AJAX 验证邮政编码之前没有任何内容可供选择。看起来效果很好,没有隐藏任何东西。

但是,在您提到的两个选项之间,我会选择第一个。那是最接近对我有用的。

I've done this before. I had the user enter street and zip code, then they had to choose what city they were from in case there was more than one to choose from. I didn't hide any fields, but there wasn't anything to choose from until the postal code was validated via AJAX. It seemed to work quite well not hiding anything.

However, between the two options that you mentioned, I would go with the first one. That one is closest to what has worked for me.

喵星人汪星人 2024-10-23 05:23:39

我想说尝试实现类似预测搜索的东西,它将城市和邮政编码字段作为搜索参数。

例如,您输入了邮政编码,单击(或按 Tab 键)到城市字段,您将获得该邮政编码适用的城市列表。

但不要强迫用户选择列表中的条目之一。

如果用户的城市不在数据库中,您可以自动填充数据库。

这就是我想要的:)

i'd say try to implement something like predictive search which takes both, city an zip field, as search params.

for example you've typed your zip code, click (or tab) to the city field, you get a list of cities where this postal code applies.

but don't force the user to take one of the entries in the list.

with that you can auto-populate your database if the user's city isn't already in it.

that's something i'd like to have :)

開玄 2024-10-23 05:23:39

地址通常是“值对象”,这意味着它们只能被实体(例如客户)读取,这意味着您应该让他们选择现有地址或创建新地址。

也就是说,这也取决于您的目标受众。他们擅长输入地址吗?例如,我总是弹出一个日期控件,这样他们就不会选择无效的日期。

您可以看看导航系统是如何工作的。他们总是询问目的地。我的系统首先在街道上自动完成,然后是门牌号,然后是城市/邮政编码。只要看看较受欢迎的单位即可。

Addresses are usually "value objects" meaning they are read only to an entity (such as a customer), which means you should probably let them pick out an existing address or create a new address.

That said, this also depends on your target audience. Are they good at entering addresses? For example, I always throw up a pop-up control for dates so there isn't a chance they would pick an invalid date.

You could look at how Navigation systems work. They always ask for a destination. Mine does an auto complete on the street first, then house number, then city / zip. Just look at the more popular units.

撩起发的微风 2024-10-23 05:23:39

只需在他们填写查找信息时禁用额外字段即可。您的 AJAX 调用不应该那么慢。如果是的话,那么除此之外你还有一些严重的问题需要解决。

但你走在正确的道路上。

just disable the extra fields while they fill in their lookup information. You AJAX calls shouldn't be that slow. If they are then you have some serious problems to address other than this.

But you are on the right path.

心房的律动 2024-10-23 05:23:39

我首先会让他们只输入邮政编码,然后我可能会提交表单并返回两个不同的表单,具体取决于您的数据库中是否有可用数据。

警告一句:人们可能对虚荣地址极其敏感。您的数据库可能显示 94027 是加利福尼亚州雷德伍德海岸,但如果您告诉自认为住在阿瑟顿的人他住在雷德伍德城,他会生气。有时,当人们输入地址信息时,最好不要做额外的工作。

I would start by having them enter just the Postal Code, and I'd probably submit the form and return two different forms depending on whether or not you have the available data in your database.

One word of warning: people can get extremely sensitive about vanity addresses. Your database probably says that 94027 is Redwood Shores, CA, but if you tell someone who thinks that he live in Atherton that he lives in Redwood City, he's going to get pissed. Sometimes, it is better not to do extra work when people are entering address information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文