Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 at 14:52
    
yes I want to check with JavaScript.... –  Thiago Aug 1 at 14:56

1 Answer 1

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)
{
                document.getElementById("idAttachmentsRow").style.display='none';
alert("Please attach Documents");
return false ;
}
else { return true ;}
}
</script>

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 at 22:51

Your Answer

 
discard

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.