简体   繁体   English

Parsley.js 除了英语字母表外还验证僧伽罗语泰米尔语(非英语字符)

[英]Parsley.js validate Sinhala Tamil (non-English characters) in addition to English alphabet

如何使用 Parsley.js 验证僧伽罗语和泰米尔语字母表通过表单验证允许非英文字符

Parsley.js offers data-parsley-pattern option ( https://parsleyjs.org/doc/ ) which can be utilized to customize the accepted character-set. Parsley.js 提供了data-parsley-pattern选项( https://parsleyjs.org/doc/ ),可用于自定义接受的字符集。 This option accepts Unicode character ranges in a regular expression.此选项接受正则表达式中的 Unicode 字符范围。

Unicode character range for Sinhala: 0D80 - 0DFF僧伽罗语的 Unicode 字符范围: 0D80 - 0DFF

Unicode character range for Tamil: 0B80 - 0BFF泰米尔语的 Unicode 字符范围: 0B80 - 0BFF

You can find the character ranges for other languages here ( http://unicode.org/charts/ )您可以在此处找到其他语言的字符范围 ( http://unicode.org/charts/ )

After collecting the Unicode ranges, give them in the data-parsley-pattern option in tag.收集 Unicode 范围后,将它们放在 tag 中的 data-parsley-pattern 选项中。

<form data-parsley-validate action="" method="post" data-parsley-pattern="^[@.a-z A-Z0-9- \u0D80-\u0DFF \u0B80-\u0BFF]+$">

Done!完毕!

You may check the regular expression here ( https://regex101.com/r/hhQOwl/1 )您可以在此处查看正则表达式( https://regex101.com/r/hhQOwl/1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM