Pure JavaScript client side validation is the simplest but least feature-rich type of Client Side Validation.
This type of validation uses 100% client-side JavaScript code to try to
validate the values entered by the user. Because the validation logic
is actually repeated in the JavaScript code, it is important to
understand that some values will be considered acceptable by the
JavaScript code but will be marked as unacceptable by the server-side Validation.
純Javascript客戶端驗證是最簡單的,但是只功能有限的客戶端驗證。這種類型的驗證用100%的客戶端javascript代碼驗證用戶錄入的值。因為驗證邏輯是javascript代碼,所以理解--一些值javascript代碼認為通過了,而服務器端的驗證可能不通過--是非常重要的。
Only the following validators are supported:
- required validator
- requiredstring validator
- stringlength validator
- regex validator
- email validator
- url validator
- int validator
- double validator
Error reporting
Because client side validation does not talk to the server, the theme (xhtml theme or css_xhtml theme)
is responsible for properly manipulating the HTML DOM to display the
error message inline. The JavaScript that is responsible for doing this
logic is validation.js and can be found in each theme.
因為客戶端的驗證不與服務器端交互,主題(....)負責操縱HTML DOM來顯示再現錯誤消息。負責這個邏輯的javascript是validation.js,能在各自的主題里找到。
 |
Errors
are reported using the default validation message, not the
internationalized version that the server-side might be aware of. This
is a known issue. You may want to try the AJAX Client Side Validation for messages that are fully internationalized. 用驗證消息顯示錯誤報告不能被國際化。你可能想用Ajax Client Side validation來是消息完全國際化。
|
Additional Validator Support
If you wish to add additional validator support beyond those listed, you may override the xhtml theme teamplte form-close-validate.ftl. This file contains the JavaScript that tries to validate each user-entered value from within the browswer. The css_xhtml theme extends the xhtml theme and therefore doesn't have it's own form-close-validate.ftl template.