Hello,
How autorize only jpg in an attachment field and file under 5mo?
thanks for your help
have a nice day
Hello,
How autorize only jpg in an attachment field and file under 5mo?
thanks for your help
have a nice day
Hello @bsteam!
Please use the below code in JavaScript Editor. It’ll validate attachment extension and size on submit.
Replace “Error text” with your message.
fd.spRendered(function() {
fd.validators;
fd.validators.push({
name: 'Check Attachment',
error: "Error text",
validate: function(value) {
if (fd.field('Attachments').value[0].extension != '.jpg'
&& fd.field('Attachments').value[0].size > '5242880')
return false;
return true;
}
});
});
thx for your help
It’s working, I need now to make a loop to test all attachments in the attachments field
this work fine thanks
fd.spRendered(function() {
fd.validators;
fd.validators.push({
name: 'Check Attachment',
error: "Uniquement JPG ou PNG de moins de 10MO",
validate: function(value) {
var i;
var t=0;
for (i = 0; i < fd.field('Attachments').value.length; i++) {
if ((fd.field('Attachments').value[i].extension != '.jpg'||fd.field('Attachments').value[i].extension != '.png')&& fd.field('Attachments').value[i].size > '10485760')
{
t++;
}
}
if(t!=0)
{
return false;
}
return true;
}
});
});