Form validation/zh-cn: Difference between revisions
From Joomla! Documentation
Zhang19min88 (talk | contribs) Created page with "更多信息: Client-side form validation" |
Zhang19min88 (talk | contribs) Created page with "服务器端校验" |
||
| Line 7: | Line 7: | ||
更多信息: [[S:MyLanguage/Client-side form validation|Client-side form validation]] | 更多信息: [[S:MyLanguage/Client-side form validation|Client-side form validation]] | ||
服务器端校验 | |||
.. is done after having submitted the form and will normally return to the form when not validated with some extra messages. <br/> | .. is done after having submitted the form and will normally return to the form when not validated with some extra messages. <br/> | ||
It uses the HTML '''attributes''' <u>required</u> ("true" or "required") and <u>validate</u> (with value being a joomla or custom rule; e.g. validate="email") | It uses the HTML '''attributes''' <u>required</u> ("true" or "required") and <u>validate</u> (with value being a joomla or custom rule; e.g. validate="email") | ||
Revision as of 14:08, 15 September 2017
Joomla的表单验证包括客户端和服务端。服务器端是必须要有的,这样能够确保你的数据是经过校验的,因为用户端的数据总是不可信的。客户端虽然不能够百分百的保证数据的有效性,但是它对于改善用户体验是非常有帮助的。因此,我们强烈建议你将两端都实现校验。
客户端校验 客户端的校验是通过javascript脚本来实现的,当用户在输入框中输入数据的时候会触发校验(一般是响应onblur事件,当输入框失去焦点时)。为了让系统知道哪一个字段需要被校验,你需要在你的输入框中增加两个类 required and validate-[xxx](其中[XXX]代表了joomla系统内置或者用户自定义的校验规则。如:validate-numeric)
更多信息: Client-side form validation
服务器端校验
.. is done after having submitted the form and will normally return to the form when not validated with some extra messages.
It uses the HTML attributes required ("true" or "required") and validate (with value being a joomla or custom rule; e.g. validate="email")
More here: Server-side form validation