From f9e284fea9413e64b0dd220125792494534f5263 Mon Sep 17 00:00:00 2001 From: Nisha-admin <167525268+Nisha-admin@users.noreply.github.com> Date: Tue, 28 Oct 2025 17:31:39 +0530 Subject: [PATCH 1/3] Add file attachment validation script An onSubmit Client script that checks for file attachment criteria. --- Check Attachment | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Check Attachment diff --git a/Check Attachment b/Check Attachment new file mode 100644 index 0000000000..2d57044521 --- /dev/null +++ b/Check Attachment @@ -0,0 +1,3 @@ +An onSubmit Client script that checks whether only one file is attached and also file type should be .doc, .pdf or .txt. Otherwise form will not be submitted and required error message will be displayed to user. + +Note: Check this property - glide.attachment.extensions From 795a4ce57fff260db2cf47ec825bf83e87d4d502 Mon Sep 17 00:00:00 2001 From: Nisha-admin <167525268+Nisha-admin@users.noreply.github.com> Date: Tue, 28 Oct 2025 17:32:54 +0530 Subject: [PATCH 2/3] Add file type validation for attachments on submit --- CheckAttachmentFiletypr.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 CheckAttachmentFiletypr.js diff --git a/CheckAttachmentFiletypr.js b/CheckAttachmentFiletypr.js new file mode 100644 index 0000000000..b134145dd1 --- /dev/null +++ b/CheckAttachmentFiletypr.js @@ -0,0 +1,30 @@ +function onSubmit() { + var arr = []; + var extension1 = '.txt'; + var extension2 = '.pdf'; + var extension3 = '.docx'; + var names = this.document.getElementsByClassName('get-attachment ng-binding ng-scope'); + for (var i = 0; i < names.length; i++) { + var val = names[i].innerHTML; + arr.push(val.toString()); + } + + var countRequired = 1; + if (window == null) { + if (this.document.getElementsByClassName('get-attachment').length != countRequired) { + g_form.addErrorMessage('You can add only one attachment'); + return false; + } + } + + for (var j = 0; j < arr.length; j++) { + if ((arr[j].indexOf(extension1) > -1) || (arr[j].indexOf(extension2) > -1) || (arr[j].indexOf(extension3) > -1)) { + return true; + } else { + g_form.addErrorMessage('Unsupported file format. Please attach files with extensions .txt, .pdf, .doc'); + return false; + } + + } + +} From f62e5788dcf09b511887172ac19382929d75233a Mon Sep 17 00:00:00 2001 From: Nisha-admin <167525268+Nisha-admin@users.noreply.github.com> Date: Thu, 30 Oct 2025 13:21:00 +0530 Subject: [PATCH 3/3] Add files via upload --- .../CheckAttchmentFileType.js | 30 +++++++++++++++++++ .../README.txt | 3 ++ 2 files changed, 33 insertions(+) create mode 100644 Client-Side Components/Catalog Client Script/Check Attachment file Type on Catalog Form/CheckAttchmentFileType.js create mode 100644 Client-Side Components/Catalog Client Script/Check Attachment file Type on Catalog Form/README.txt diff --git a/Client-Side Components/Catalog Client Script/Check Attachment file Type on Catalog Form/CheckAttchmentFileType.js b/Client-Side Components/Catalog Client Script/Check Attachment file Type on Catalog Form/CheckAttchmentFileType.js new file mode 100644 index 0000000000..e1a64325fd --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Check Attachment file Type on Catalog Form/CheckAttchmentFileType.js @@ -0,0 +1,30 @@ +function onSubmit() { + var arr = []; + var extension1 = '.txt'; + var extension2 = '.pdf'; + var extension3 = '.docx'; + var names = this.document.getElementsByClassName('get-attachment ng-binding ng-scope'); + for (var i = 0; i < names.length; i++) { + var val = names[i].innerHTML; + arr.push(val.toString()); + } + + var countRequired = 1; + if (window == null) { + if (this.document.getElementsByClassName('get-attachment').length != countRequired) { + g_form.addErrorMessage('You can add only one attachment'); + return false; + } + } + + for (var j = 0; j < arr.length; j++) { + if ((arr[j].indexOf(extension1) > -1) || (arr[j].indexOf(extension2) > -1) || (arr[j].indexOf(extension3) > -1)) { + return true; + } else { + g_form.addErrorMessage('Unsupported file format. Please attach files with extensions .txt, .pdf, .doc'); + return false; + } + + } + +} \ No newline at end of file diff --git a/Client-Side Components/Catalog Client Script/Check Attachment file Type on Catalog Form/README.txt b/Client-Side Components/Catalog Client Script/Check Attachment file Type on Catalog Form/README.txt new file mode 100644 index 0000000000..bcf7f8d6b0 --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Check Attachment file Type on Catalog Form/README.txt @@ -0,0 +1,3 @@ +An onSubmit Client script that checks whether only one file is attached and also file type should be .doc, .pdf or .txt. Otherwise form will not be submitted and required error message will be displayed to user. + +Note: Check this property - glide.attachment.extensions \ No newline at end of file