# 添付ファイルの無し判定

**URL:** <https://community.cybozu.dev/t/topic/3293>\
**Category:** kintone 開発相談\
**Created:** [2018 年 8 月 14 日午前 8:13 UTC](https://community.cybozu.dev/t/topic/3293 "2018-08-14T08:13:19Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Legacy\_Account1821](https://avatars.discourse-cdn.com/v4/letter/l/d07c76/32.png) [@Legacy\_Account1821](https://community.cybozu.dev/u/Legacy_Account1821)\
**Post date:** [2018 年 8 月 16 日午前 1:51 UTC](https://community.cybozu.dev/t/topic/3293/6 "2018-08-16T01:51:37Z")

</div>

rex0220さん、

ありがとうございます。その手がありましたね。

&nbsp;

k\_chinenさん

勉強も兼ねて作ってみました。

```
(function() {
"use strict";
kintone.events.on([
"app.record.create.submit",
"app.record.edit.submit"
], function(event) {

var record = event.record;

// 添付ファイルのファイル名DOM要素の配列数取得
var count = document.getElementsByClassName('plupload_file_name').length;

// ファイル無し＝配列数０の場合は添付ファイルフィールドにエラー表示
if (count === 0) {
record['添付ファイル']['error'] = '添付ファイルを登録してください';
}

return event;
});
})();

```

こんな感じでチェックできるかと思います。

---

_[View the full topic](https://community.cybozu.dev/t/topic/3293)._
