SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I open(edit) some item in a list I want to check with JavaScript if the user has attached any file in my Edit Form...

enter image description here

share|improve this question
You'll need to provide some more context here... I understand you want to check if a user attached a file, but what are you attempting to do with the results? Are you looking to use javascript to check the edit form before an item is first submitted? Are you looking to check if items that were submitted have an attachment? – John-M Aug 1 '14 at 14:52
yes I want to check with JavaScript.... – Thiago Aug 1 '14 at 14:56
up vote 3 down vote accepted

You can add this script:

<script type="text/javascript" language="javascript">
function PreSaveAction() {
            var elm = document.getElementById("idAttachmentsTable");
            if (elm == null || elm.rows.length == 0)
alert("Please attach Documents");
return false ;
else { return true ;}

Works very nice!

Does not work with SharePoint 2013, since it does not have "PreSaveAction"

share|improve this answer
thanks man! it works – Thiago Aug 1 '14 at 22:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.