How to validate the attached file is jpg on ui builder experience and show pop up if it is not jpg

sony8
Tera Contributor

Hi ,

 

I have below requirement,

I created a variable of type attachment, and variable attributes I have added add extension =jpg.

when I am attaching the file other jpg it was not attaching, if it is jpg it is allowing to attach.

 

I want an error message when a user attach other than jpg.

how to validate this on ui builder experience?

6 REPLIES 6

Samaksh Wani
Giga Sage
Giga Sage

Hello @sony8 

 

const file = this.files[0];
const  fileType = file['type'];
const validImageTypes = [ 'image/jpg'];
if (!validImageTypes.includes(fileType)) {
    // invalid file type code goes here.
alert('your popup message')
}

 

Plz mark my solution as Accept, If you find it helpful.

 

Regards,

Samaksh

@Samaksh Wani  I need to write onchange client script ?

Hello @sony8 

 

Yes you can write on change client script.

 

Plz mark my solution as Accept, If you find it helpful.

 

Regards,

Samaksh

Hello @sony8 

 

Also you will be having one more approach.

 

Screenshot 2023-10-12 at 11.30.29 AM.png

 

You can go to variable > In Variable Attribute.

 

allowed_extension=jpg

 

Plz mark my solution as Accept, If you find it helpful.

 

Regards,

Samaksh