开发者

Forgiving Format design pattern - JQuery or C# library?

I have just been looking at the 'Forgiving Format' design pattern (e.g. http://ui-patterns.com/patterns/Forgiv开发者_如何转开发ingFormat), however I am surprised that I can't find any libraries implementing this (specifically for simple date/times). Does anybody know of any (perferably open source) libraries for this?

Thanks


I don't think this is a design pattern, rather a UI pattern... (edit: i just noticed the name of the website you linked to :) )

As a matter of fact, this functionality exists in some libraries. The first one to spring to mind is dateJS, a javascript parsing library that allows for fuzzy date input. However since i last heard of it, there hasn't been much activity in the project.

Apart from dates, countries, etc... , i think that any project of this kind is very business-specific; first you've got to learn how users express themselves and how to translate this in business terms. Working on a generic translator doesn't look like it's feasible, at least not without a lot of configuration.


The Forgiving Format design pattern is heavily dependent upon your interface. If you are using HTML 4 and have only a text box, how is it supposed to know that only numbers are acceptable? How is it supposed to know that 2.30 is supposed to mean 2:30 as in hour of the day? Et cetera.

There are jQuery plugins which steer user input in the right direction using general rules, however you're the one to determine what is acceptable and what isn't in the end. And if you wanted to have a field which accepted either telephone numbers or e-mail addresses, you'd be hard-pressed to find a library which validates it as such without a little tweaking.

Ultimately it comes down to you to be able to determine what is tolerated input and what isn't. Libraries merely help you do the more common validation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜