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

Clear fields based on drop-down values in PowerApps

Hide a SharePoint list field based on user group using JQuery Webservice in 2010