Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Added script for max validation check (#422)

Sudheer reddy78b839cfb8da
diff --git a/src/Web/Grand.Web/vueapp/src/main.js b/src/Web/Grand.Web/vueapp/src/main.js
index d47900448..e121032ab 100644
--- a/src/Web/Grand.Web/vueapp/src/main.js
+++ b/src/Web/Grand.Web/vueapp/src/main.js
@@ -239,7 +239,38 @@ extend('required', {
return 'The ' + fieldName + ' field is required.'
}
});
+extend('max', {
+ params: ['target'],
+ options: {
+ hasTarget: true
+ },
+ validate: function (value, ref) {
+ const maxVal = ref.target;
+ const length = value.length;
+
+ if (!value) {
+ return true;
+ }
+
+ if (length > maxVal) {
+ return false;
+ }
+ if (length === maxVal) {
+ return true;
+ }
+ return true;
+ },
+ message: (fieldName) => {
+ const text = vee_getMessage(fieldName, 'max');
+ if (text) {
+ return text;
+ }
+ const element = document.getElementsByName(fieldName);
+ let maxLength = element[0].maxLength;
+ return 'This ' + fieldName + ' should be at most ' + maxLength + ' characters.';
+ }
+});
extend('min', {
params: ['target'],
options: {