]> glassweightruler.freedombox.rocks Git - Ventoy.git/blobdiff - Plugson/www/static/js/jquery.validate.vtoymethods.js
1.1.07 release
[Ventoy.git] / Plugson / www / static / js / jquery.validate.vtoymethods.js
index 624c40e59d01ad416c665fa571a42eb74f5d085e..9e640b9b681585cb8387cacd26788938245d308f 100644 (file)
@@ -1,3 +1,16 @@
+function ventoy_check_file_name_char(path) {\r
+    for (var i = 0; i < path.length; i++) {\r
+        var cc = path[i];\r
+        if (cc === '/' || cc === '\\' || cc === '*' || cc === '?' || cc === '"' || cc === '<' || cc === '>' || cc === '|')\r
+        {\r
+            return false;\r
+        }\r
+    }\r
+\r
+    return true;\r
+}\r
+\r
+\r
 (function(factory) {\r
     if (typeof define === "function" && define.amd) {\r
         define(["jquery", "../jquery.validate"], factory);\r
 \r
         return true;\r
     }, 'Can not contain double quotes');\r
+\r
+    $.validator.addMethod('filenamepart', function(value, element, params) {\r
+        if (this.optional(element)) {\r
+            return true;\r
+        }\r
+\r
+        return ventoy_check_file_name_char(value);\r
+    }, 'Invalid characters');\r
     \r
 \r
     $.validator.addMethod('printascii', function(value, element, params) {\r