I have a custom list form that implements OOTB file upload control to add attachments to the list item. Upon save, the attachments are saved to the item. But before saving the list item with attachments, I would like to validate for the following:

  1. Limit only one attachment per list item.
  2. Validate for attachment size which should not be more than 250KB.

Please let me know if the above can be implemented. Thank you.


2 Answers 2


To get this information I would recommend you to implement a SPItemEventReceiver.Item.AttachmentAdding Event Receiver. When a new attachment will be added you can cancel this event when there is already a attachment on the list item. For validation of the file size you might need first upload the attachment and delete it, when it is to large.

The items will be uploaded to SharePoint independently after the list item have been created.


Listen for the change event on the input.

Get the size of the file by this. files[0]. size.

You can round off the obtained value as well by the toFixed() method.

Check if the size follows your desired criteria.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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