How to Validate File attachment Name in SharePoint List in Sharepoint 2010?
Hi Sharepointers,
If you want to validate the sharepoint file attachment name in Sharepoint 2010, please attach the following script in Content editor web part in the list addform and editform.aspx.
<script type=”text/javascript”>
function PreSaveAction()
{
var attachment;
var filename=””;
var fileNameSpecial = new RegExp(“[~#%&*{}<>;?/+|\”]”);
try {
attachment = document.getElementById(“idAttachmentsTable”).getElementsByTagName(“span”)[0].firstChild;
filename = attachment.data;
}
catch (e) {
}
if (fileNameSpecial.test(filename)) {
alert(“Please remove the special characters from the file attachment name.”);
return false;
}
else {
return true;
}
}
</script>
Hope it helps!! Happy Sharepointing guys!!