在客户端验证时显示提示语句_当仅客户端验证对企业有利时

在客户端验证时显示提示语句_当仅客户端验证对企业有利时

在客户端验证时显示提示语句

the validation. This is a rule, never to be broken. But here's a funny story how skipping the server-side validation actually helped. 验证。 这是一条规则,永不被打破。 但是,这是一个有趣的故事,跳过服务器端验证实际上有何帮助。

This is a real story, but the actual names have been replaced in XXX, just not to make other people look bad ????

这是一个真实的故事,但是实际名称已在XXX中替换,只是为了不让其他人看起来很糟????

There is this site called xxxxxxxxx.com that charges you $XX membership access. Having just moved from Canada, last year I didn't have a US credit card to pay the fee and tried to use my Canadian visa. Problem: the input field for postal code (zip code) accepts 5 characters only, since the zip codes in US a like 90404, 90066 and so on. A Canadian postal code is like H0H-0H0 or H0H0H0, six characters. So seemed like I couldn't pay online. Or could I?

有一个名为xxxxxxxxx.com的网站,向您收取$ XX会员访问费用。 刚从加拿大移居之后,去年我没有美国信用卡来支付这笔费用,并试图使用我的加拿大签证。 问题:邮政编码(邮政编码)的输入字段仅接受5个字符,因为邮政编码在美国类似于90404、900066等。 加拿大邮政编码类似于H0H-0H0或H0H0H0,六个字符。 因此,似乎我无法在线付款。 还是可以吗?

Checking the source code with Firebug gives me this:

使用Firebug检查源代码可以得到以下信息:

在客户端验证时显示提示语句_当仅客户端验证对企业有利时

From here it's trivial to change maxlength attribute of the input. Even with IE it's super easy just to type in the address bar something like: javascript:document.getElementsByName('XXXXXXX')[0].maxLength = 100;

从这里更改输入的maxlength属性很简单。 即使使用IE,也很容易在地址栏中输入如下内容: javascript:document.getElementsByName('XXXXXXX')[0].maxLength = 100;

So I did change it, typed my Canadian CC#, Canadian postal code and submitted the form, crossing fingers that the developers who built the site were too pressed by deadlines to do a proper server-side validation. Lo and behold, it worked!

因此,我确实进行了更改,键入了我的加拿大CC#,加拿大邮政编码并提交了表格,但手指交叉地指出,构建该网站的开发人员在截止日期之前过于紧张,无法进行适当的服务器端验证。 瞧,它成功了!

At the end with the help of an innocent client-side tweak I got what I needed (membership), xxxxxxxx.com got more business, and everybody's happy.

最终,在无辜的客户端调整的帮助下,我得到了我所需要的(成员身份),xxxxxxxx.com获得了更多的业务,每个人都很高兴。

There's a lesson in this: sometimes being too strict in data validation for things that don't matter is just in your way. And another: don't assume all your potential clients are from US.

这方面有一个教训:有时候,对无关紧要的数据验证过于严格只是您的方式。 还有一个:不要以为您的所有潜在客户都来自美国。

Tell your friends about this post on Facebook and Twitter

FacebookTwitter上告诉您的朋友有关此帖子的信息

翻译自: https://www.phpied.com/when-client-only-validation-is-good-for-business/

在客户端验证时显示提示语句