How to Create a validation to a list form for "Attach File" for SharePoint

Sometimes the little code - works!
How to do on MOSS 2007 list form a requirement to the attach field?

 

Let build up a validation in JavaScript

The following JS code do it perfectly. All you need is access to the SharePoint Designer. Edit the form (NewForm.aspx or EditForm.aspx). Find a good place to insert the code in the list form, And Copy-Paste the code:
<script type="text/javascript" language="javascript>
function
 PreSaveItem() {
  var elm = document.getElementById("idAttachmentsTable");
  if
 (elm == null || elm.rows.length == 0)
  {
    alert("Please attach a document to the request");
    return
 false;
  }
  if ("function" == typeof (PreSaveAction))
  {
    return
 PreSaveAction();
  }
  else
    return
 true;
}
</
script>

I Love JavaScript
Roi

Comments

Popular posts from this blog

A sharepoint list view of the current month

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters

Export SharePoint 2010 List to Excel with PowerShell