Pergunta

I am trying to make some fields mandatory for creating a bug in Bugzilla, from what I have read, the easiest way is by using JavaScript. The code I have used is shown below but doesnt seem to be working. My Javascript knowledge is pretty limited so i am presuming it is an error in my coding.

        <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();">
Foi útil?

Solução

I believe the problem is this line:

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

and all other places where you use this. Try document instead.

It would be a big help if you include the FORM markup (or a sample if its big) as that is relevant.

Outras dicas

I had the same issue, but i made a extension. Using hook system to translate fields with "*", in the names, to validate like required field. This is a simple solution not intrusive where is not required addition of fields in the database, only by the use of sufix "*" in configuration of custom fields.

There is the code: https://github.com/voiski/bugzilla-required-field

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top