Make attachment required field in SharePoint List/ Library

<script type="text/javascript" language="javascript">
function PreSaveAction()
{
  var elm = document.getElementById("idAttachmentsTable");
    if (elm == null || elm.rows.length == 0)
 {
       document.getElementById("idAttachmentsRow").style.display='none';
  alert("Please Attach File");
  return false ;

 }
 else {
 return true ;
 }
 return true ;
}
</script>
--------------------------------------------
If need confirmation box. Please use the below code

function PreSaveAction()
{
      var elm = document.getElementById("idAttachmentsTable");
               if (elm == null || elm.rows.length == 0)
            {
var r=confirm("Do you want to attach the file?");
if(r==true)
        {
return false;
}
  else
{
return true;

}

                }
      else
{
return true;
}

     return true ;
}


Comments

Popular posts from this blog

SharePoint 2016 and 2019 Ports

PsConfig step by step /Configuration Wizard. “Upgrade Available” vs “Upgrade required”

Unlock the SharePoint site using Powershell command