1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Googleフォームの記述式テキスト欄をGASから数値のみ入力に指定する

Posted at

はじめに

 ご存知の方も多いとは思いますが、Googleフォームとは無料でアンケートの作成や集計ができるサービスです。
 
 フォームの編集画面から大抵の事はできますが、Google スプレッドシートと連携させたいときはGoogle Apps Script(GAS)を使うことが出来ます。

 今回は、GASから記述式テキスト欄への入力を数値のみに制限する方法について記事にします。

方法

function createTextbox(){
  //フォームの作成
  const form = FormApp.create("フォーム");
  
  //入力規則を作成
  var textValidation = FormApp.createTextValidation()
  .requireNumber()
  .build();
  
  //テキスト入力フォームの作成
  form.addTextItem().setTitle('テキスト').setValidation(textValidation); 
}

作成されたフォーム

フォーム.PNG

 無事に数値以外の入力が弾かれています。

おわりに

 フォームの編集画面からでも設定できるので、この記事に需要はあるのか...

 ご覧いただきありがとうございました。質問・ご指摘等ありましたらよろしくお願いします。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?