1

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?

  • Google Apps Script runs on a Google server. It does not have direct access to DOM of the forms, sheets, or documents. So, no way to do what you want. – user135384 Jan 5 '17 at 21:08
  • @zaq Maybe I can use it to add additional Javascript to form? – Arek Jan 6 '17 at 6:46
  • No, Google Apps Script cannot add script elements to the page with the form. They have no direct access to that page, period. – user135384 Jan 6 '17 at 6:47
  • @zaq Google Apps Script could to this, as I briefly described on my answer. I will add some notes like the difference of the old and the new forms. – Rubén Jan 6 '17 at 21:11
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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