如题,Web开发根本法则之一就是不能相信用户的输入,那么表单验证器(form validator)是必须的啦。偶用过的表单验证器有formencode,不过觉得有点麻烦,大家在开发中有什么好推荐吗?
基于12个网页-相关网页
要使用定制验证器,必须将其添加到表单,并为它传递需要被验证的那些字段元素,如清单 14 所示。
To use a custom validator you must add it to the form, passing it field elements on which the validation needs to be applied, as shown in Listing 14.
定制验证器需要在表单实例化的时候添加到此表单。
Custom validators need to be added to the form at the time of form instantiation.
清单7停止默认动作执行(阻止表单提交到服务器),然后验证是否选择了搜索引擎。
Listing 7 stops the default action from running (it prevents the form from submitting to the server) and then validates that a search engine has been selected.
应用推荐