用什么JavaScript库的客户端形式的检查?客户端、形式、JavaScript

2023-09-11 01:37:11 作者:仙女味奥利奥

多年来,我已经涉足普通的JavaScript一点,但还没有使用任何JavaScript / AJAX库。对于一些新的东西,我的工作,我想用一个JS库做客户端表单验证,并想知道这将是最好的一个。通过最好的,我的标准是:快速,简单易学,占地面积小,兼容所有流行的浏览器。

Over the years, I've dabbled in plain JavaScript a little, but have not yet used any JavaScript/AJAX libraries. For some new stuff I'm working on, I would like to use a js library to do client-side form validation, and want to know which would be best for that. By best, my criteria would be: quick and easy to learn, small footprint, compatible with all popular browsers.

编辑:谢谢你的ASP的建议,但他们没有与我有关。对不起,我最初没有提到它,但服务器运行的Apache和PHP Linux机器。当我知道我要的,我打算做输入服务器端验证,但希望在客户端验证,提高了用户体验,避免尽可能让服务器拒绝无效的投入。

Thanks for the ASP suggestions, but they're not relevant to me. Sorry I didn't originally mention it, but the server is a Linux box running Apache and PHP. As I know I should, I plan to do server side validation of the input, but want the client side validation to improve the users' experience and to avoid as much as possible having the server reject invalid inputs.

编辑2:对不起,我没有几个月回复!其他优先事项上来,并从该改行了我。最后我做我自己的验证程序 - 除了一些答案提出的好点,有些我验证的项目很少用于其他应用程序,我不能找到那种验证包括库

Edit 2: Sorry I didn't reply for months! Other priorities came up and diverted me from this. I ended up doing my own validation routines - in addition to the good points made in some of the answers, some of the items I'm validating are rarely used in other applications and I couldn't find a library with that sort of validation included.

推荐答案

我不图书馆自己使用,而是一头扎进了一些(如原型,(yui-)分机,看似全方位present jQuery的,mootools的)向他们学习并提取了一些他们所提供的功能或模式。该库(又名框架)中含有大量的functionallity我永远需要的,所以我写我自己的功能子集。表检查是pretty的难以标准化(除非是像电话号码或电子邮件地址字段),所以我不认为一个框架,将有助于有两种。我的建议是,以检查库中的一个给你找后的功能,和/或使用/重写/复制,你可以从他们使用的功能。对于大多数的开源库,可以下载uncom pressed源。

I don't use libraries myself, but dived into some (like prototype, (yui-)ext, the seemingly omnipresent jquery, mootools) to learn from them and extract some of the functions or patterns they offer. The libraries (aka 'frameworks') contain a lot of functionallity I never need, so I wrote my own subset of functions. Form checking is pretty difficult to standardize (except perhaps for things like phone numbers or e-mail address fields), so I don't think a framework would help there either. My advice would be to check if one of the libraries offer the functionallity you look for, and/or use/rewrite/copy the functions you can use from them. For most open source libraries it is possible to download the uncompressed source.

这需要说(顺便说一下,也许众所周知媒体链接)的客户端形式的检查,被认为是不够的。你必须得检查输入服务器端。

It needs to be said (by the way and perhaps well known allready) that client side form checking is regarded insufficient. You'll have to check the input server side too.