Google Forms – Set Input Type to Tel for Answer Input Field

google-apps-scriptgoogle-forms

In my Google Form I've got multiple text questions with answers with data validatation set to numbers only. Unfortunately when I enter the answers using the mobile browser the keyboard shown is full, not numbers only.

So I want to change the input type of all those fields to "tel". It should be possible if I found the way to manipulate DOM of the form after form loads. However my Google Apps Script knowledge is very limited.

My question is: Could you write the example of the function which changes input fields' type of Google Form after it loads?

Best Answer

Short answer

This could be done by using the Url Fetch and Html Service from Google Apps Script.

Explanation

With UrlFetchApp you could do GET/POST to the Google Forms servers, get the response to manipulate it and finally serve it as a web page by using the Html Service.

The broad idea behind the above was "on the wild" from a time ago. If found mentions of a Google Forms add-on called FormFuse that I think that works this way and a WordPress plug-in that does something similar.

It's worth to mention that currently there are two versions of Google Forms, the old and the new, as they are called by Google. The new version are generathe by Google Closure Compiler and the compiled form uses the JSAction library. The old version uses regular html forms, for me, this version is easier than the newer, as there are some tutorials that were made based on this version, like https://morningstudio.com.au/blog/2013/06/how-to-style-google-forms/. This tutorial doesn't use Google Apps Script but shows the broad concept.

A visual walk-through will be too long for this format. Please learn as much as you can of Google Apps Script and post new specific follow up questions.

Resources

Related questions