]>
glassweightruler.freedombox.rocks Git - Ventoy.git/blob - Plugson/www/static/js/jquery.validate.vtoymethods.js
1 function ventoy_check_file_name_char(path
) {
2 for (var i
= 0; i
< path
.length
; i
++) {
4 if (cc
=== '/' || cc
=== '\\' || cc
=== '*' || cc
=== '?' || cc
=== '"' || cc
=== '<' || cc
=== '>' || cc
=== '|')
15 if (typeof define
=== "function" && define
.amd
) {
16 define(["jquery", "../jquery.validate"], factory
);
22 // 设置validator插件默认校验格式
23 $.validator
.setDefaults({
24 highlight: function(element
) {
25 $(element
).closest('.form-group').addClass('has-error');
27 success: function(label
) {
28 label
.closest('.form-group').removeClass('has-error');
35 $.validator
.addMethod('password', function(value
, element
, params
) {
36 if (this.optional(element
)) {
39 var re
= /^[^\u4e00-\u9fa5]{1,64}$/;
40 return re
.test(value
);
43 $.validator
.addMethod('utfmaxlen', function(value
, element
, params
) {
44 if (this.optional(element
)) {
48 if (ventoy_get_ulen(value
) > 250) {
55 $.validator
.addMethod('start_slash', function(value
, element
, params
) {
56 if (this.optional(element
)) {
60 if (value
.length
> 0 && value
.charCodeAt(0) != 47) {
65 }, 'Must start with /');
67 $.validator
.addMethod('noquotes', function(value
, element
, params
) {
68 if (this.optional(element
)) {
72 if (value
.length
> 0 && value
.indexOf('"') >= 0) {
77 }, 'Can not contain double quotes');
79 $.validator
.addMethod('filenamepart', function(value
, element
, params
) {
80 if (this.optional(element
)) {
84 return ventoy_check_file_name_char(value
);
85 }, 'Invalid characters');
88 $.validator
.addMethod('printascii', function(value
, element
, params
) {
89 if (this.optional(element
)) {
93 for (var i
= 0; i
< value
.length
; i
++) {
94 if (value
.charCodeAt(i
) > 127) {
99 if (value
.length
> 0 && value
.indexOf('"') >= 0) {
104 }, 'Can only use printable ascii code');