14 August 2011

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

No comments:

Post a Comment