0

我正在尝试强制某些字段在 Bugzilla 中创建错误,根据我的阅读,最简单的方法是使用 JavaScript。我使用的代码如下所示,但似乎不起作用。我的 Javascript 知识非常有限,所以我认为这是我的编码错误。

        <script type="text/javascript">
        <!--
            function mandatory_text_check(){
               if (this.form.short_desc.value == '')
               {
               alert('Please enter a summary sentence for this [% terms.bug %].');
               return false;
               }
               else if (this.form.estimated_time.value == '0.0' && this.form.cf_issuetype.value == 'Task')
               {
               alert('Please enter an estimated time for completion of this task.');
               return false;
               }
               else
               return true;
            }
        -->
        </script>



// Function is called from the commit button on the bottom of the page


      <input type="submit" id="commit" value="Commit"
             onclick="mandatory_text_check();">
4

2 回答 2

0

我相信问题出在这一行:

if (this.form.short_desc.value == '')

以及您使用的所有其他地方this。试试document吧。

如果您包含相关的FORM标记(或样本,如果它很大),这将是一个很大的帮助。

于 2010-08-18T16:50:17.437 回答
0

我有同样的问题,但我做了扩展。使用钩子系统翻译名称中带有“*”的字段,以验证类似的必填字段。这是一个简单的解决方案,不需要在数据库中添加字段,只需在自定义字段配置中使用后缀“*”即可。

有代码:https ://github.com/voiski/bugzilla-required-field

于 2014-04-28T03:45:54.330 回答