on 07-23-2014 8:38 PM
Hello Guru's,
I have a requirement to restrict the file types when adding attachment in Adobe Interactive Form.
Below is the code I have in Validate Event:
It is setting focus when adding document which is not PDF, but when I correct it and give a valid PDF document the focus is still on the field.
Please help me to remove the focus when I attach a PDF file.
if( this.rawValue == null )
{
}
else{ var fileName = this.rawValue;
var ext = fileName.substr(fileName.lastIndexOf('.')+1);
if(ext == "PDF" || ext == "pdf")
{
}
else
{
app.alert("Please select a valid PDF file");
FilePath.validate.nullTest = "error";
xfa.host.setFocus("InteractiveForm.SubForm.row_3.FilePath");
}
}
Thanks,
Pramod
hi
it seem there is a problem with java code, i believe when the file is attached to the form the value of field is not changed yet, you can try your code in CHANGE event instead of validate and see how it works.
there is another example of java code that you can fit to your requirement.
function checkFile(fieldObj)
{
var FileName = fieldObj.value;
var FileExt = FileName.substr(FileName.lastIndexOf('.')+1);
var FileSize = fieldObj.files[0].size;
var FileSizeMB = (FileSize/10485760).toFixed(2);
if ( (FileExt != "pdf" && FileExt != "doc" && FileExt != "docx") || FileSize>10485760)
{
var error = "File type : "+ FileExt+"\n\n";
error += "Size: " + FileSizeMB + " MB \n\n";
error += "Please make sure your file is in pdf or doc format and less than 10 MB.\n\n";
alert(error);
return false;
}
return true;
}
hope this helps,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ali, Thanks for the reply. When I have the code in Change Event, the control doesn't even go to the code. I tried keeping app.alert to see if it calls Change event, but in my case it doesn't call it. And the code which you have suggested didn't work. it doesn't even give alert message. Any other ideas? Thanks, Pramod
This code fixed the issue. Thanks, Pramod if( this.rawValue == null ) { } else{ var fileName = this.rawValue; var ext = fileName.substr(fileName.lastIndexOf('.')+1); if(ext == "PDF" || ext == "pdf") { FilePath.validate.nullTest="disabled"; FilePath.border.edge.color.value="255,255,255"; } else { app.alert("Please select a valid PDF file"); FilePath.validate.nullTest = "error"; } }
Anyone any ideas on how to fix this. Thanks, Pramod
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.