要求的Google脚本HTML选择不起作用 [英] Google script HTML select required did not work

查看:40
本文介绍了要求的Google脚本HTML选择不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码(我正在使用Materialize CSS框架):

Code (I'm working with Materialize CSS framework):

<form class="col s12" id="formRequer">     
      <div class="input-field col s6">
        <select id="stdApply" name="stdApply" required>
          <option value="" disabled selected>Escolha somente uma das opções</option>
          <option value="1">Option 1</option>
          <option value="2">Option 2</option>
          <option value="3">Option 3</option>
        </select>
        <label>Selecione o que quer requerer</label>
      </div>      
  </form>   <!-- END: form class="col s12" id="formRequer -->  


<button class="btn waves-effect waves-light" type="submit" id="btn_submitRequer" form="formRequer">Enviar
  <i class="material-icons right">send</i>
</button>

我复制了不包括CSS的代码,并将其粘贴到w3school上,效果很好!

I copied the code excluding CSS and paste it on w3school and it worked fine!

HTMLService evalute()进程是否有可能从标记中排除必需的属性,或者从第一个选项中排除value ="属性(这对于HTML5 select标记与必需属性一起使用至关重要)?

Is it possible that HTMLService evalute() process exclude the required attribute from tag or exclude the value="" attribute from the first option (this is vital for HTML5 select tag works with required attribute)?

有帮助吗?

推荐答案

尝试一下:

HTML:

<html>
<head></head>
<body>
  <form>     
   <select id="stdApply" name="stdApply">
     <option value="" selected>Escolha somente uma das opções</option>
     <option value="1">Option 1</option>
     <option value="2">Option 2</option>
     <option value="3">Option 3</option>
   </select>
   <label>Selecione o que quer requerer</label>
   <br /><input type="button" value="Enviar" onClick="processForm(this.parentNode);" />
  </form>  
  <script>
    function processForm(obj) {
      if(obj.stdApply.value!='') {
        google.script.run.processForm(obj);
      }else{
        document.getElementById('stdApply').focus();
      }
    }
  </script>
</body>
</html>

Google脚本:

function processForm(obj) {
  Browser.msgBox(obj.stdApply);
}

function showMyDialog() {
  SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutputFromFile('ah3'), 'Test');
}

这篇关于要求的Google脚本HTML选择不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆