2016-06-16 20 views
0

私は、選択リストを選択するときにコメントフィールド(テキストエリア)を必須にするJavaスクリプトを作成したいと思います。それにコードがついてしまった。私のウェブサイトのJavaScriptを選択に基づいて選択する必要があります。選択リスト

<select id="ddlViewBy"> 
<option value="1">AJS.$("#comment-popup").parent().children('label').append('<span class="aui-icon icon-required"></span>');</option> 

ソースコード::あなたがアトラシアン内部の作業のように

<form action="/jira/rest/tempo-rest/1.0/worklogs/{issueKey}" class="aui tempo-form" data-form-type="" name="tempo-panel-form-popup" method="post"> 
<div class="form-body" style="max-height: 393px;"> 
    <input type="hidden" name="id" value=""> 
    <input type="hidden" name="type" value="issue"> 
    <input type="hidden" name="use-ISO8061-week-numbers" value="false"> 
    <input type="hidden" name="ansidate" value=""> 
    <input type="hidden" name="ansienddate" value=""> 
    <input type="hidden" name="selected-panel" value=""> 
    <input type="hidden" name="analytics-origin-page" value=""> 
    <input type="hidden" name="analytics-origin-view" value=""> 
    <input type="hidden" name="analytics-origin-action" value=""> 
    <input type="hidden" name="startTimeEnabled" value="false"> 
    <input type="hidden" name="tracker" value="false"> 
    <input type="hidden" name="preSelectedIssue" class="tempoIssueKey" value="AB-5048"> 
    <input type="hidden" name="planning" value="false"> 
    <div class="field-group"> 
     <label for="user-picker-popup">User</label> 
     <div class="tempo-pickers"> 
      <div class="aui-ss medium aui-ss-has-entity-icon" id="user-picker-popup-single-select"> 
       <input autocomplete="off" class="text aui-ss-field ajs-dirty-warning-exempt" id="user-picker-popup-field"> 
       <div class="aui-list" id="user-picker-popup-suggestions" tabindex="-1"></div><span class="icon aui-ss-icon noloading drop-menu"><span>More</span></span><img class="aui-ss-entity-icon" alt="" src="google.pl"> </div> 
      <select id="user-picker-popup" class="plan-user-picker dialog-user-picker aui-ss-select" name="user" data-container-class="medium" data-counter="popup" data-input-text="Jon Smith" multiple="multiple" style="display: none;"> 
       <optgroup id="tempo-user-suggested-popup" data-weight="0" label=""> 
        <option selected="selected" style="background-image:url(/jira/secure/useravatar?size=small&amp;ownerId=jsmith&amp;avatarId=12927)" value="jsmith">Jon Smith</option> 
       </optgroup> 
      </select> 
     </div> 
    </div> 
    <div class="field-group tempo-issue-container"> 
     <label for="tempo-issue-picker-popup">Issue </label> 
     <div class="aui-ss" id="tempo-issue-picker-popup-single-select"> 
      <input autocomplete="off" class="text aui-ss-field ajs-dirty-warning-exempt" id="tempo-issue-picker-popup-field"> 
      <div class="aui-list" id="tempo-issue-picker-popup-suggestions" tabindex="-1"></div><span class="icon aui-ss-icon noloading drop-menu"><span>More</span></span> 
     </div> 
     <select id="tempo-issue-picker-popup" class="tempo-issue-picker tempo-picker-all-issues tempo-issue-picker-logwork aui-ss-select" name="issue" multiple="multiple" style="display: none;"> 
      <option selected="selected" value="AB-5048">AB-5048 - Holiday - Jon Smith 2016-06-13-2016-06-13</option> 
     </select> 
    </div> 
    <div class="tempo-datepicker"> 
     <div class="field-group tempo-show-period"> 
      <label for="showPeriod-popup">Period</label> 
      <div class="checkbox"> 
       <input id="showPeriod-popup" name="showperiod" type="checkbox" value="showperiod" class="showperiod tempo-show-period"> </div> 
     </div> 
     <div class="field-group datepicker "> 
      <label for="datefield-popup">Date</label> 
      <input type="text" id="datefield-popup" name="date" size="7" value="2016-06-09" class="text medium-field"> <span id="datefield-trigger-popup" class="aui-icon icon-date tempo-datepicker-trigger" tabindex="0">Select a date</span> </div> 
     <div class="field-group enddate datepicker " style="display: none;"> 
      <label for="enddate-popup">End date</label> 
      <input type="text" id="enddate-popup" name="enddate" size="7" value="2016-06-09" class="text medium-field"> <span id="enddate-trigger-popup" class="aui-icon icon-date tempo-datepicker-trigger" tabindex="0">Select a date</span> </div> 
    </div> 
    <div class="tempo-timepicker resetable"> 
     <div class="field-group tempo-worked-hours"> 
      <label class="timepicker-label" tmp="Work per day" for="time-popup">Worked </label> 
      <input autocomplete="off" type="text" id="time-popup" name="time" size="3" value="" class="tempo-time text short-field"> </div> 
     <div class="remaining-and-billed-hours-container"> 
      <div class="field-group tempo-logged-work"> 
       <label for="totalSpent-popup">Logged</label> <span class="totalSpent" id="totalSpent-popup">8h</span> </div> 
      <div class="field-group tempo-remaining-estimate" style="clear: left;"> 
       <label for="remainingEstimate-popup">Remaining estimate </label> 
       <input type="hidden" id="remainingEstimateHidden-popup" size="3" maxlength="6" value=""> 
       <input type="text" id="remainingEstimate-popup" name="remainingEstimate" size="3" maxlength="6" value="" class="validate remaining resetable text short-field"> </div> 
      <div class="field-group tempo-original-estimate"> 
       <label for="originalEstimate-popup">Original estimate</label> <span class="originalEstimate" id="originalEstimate-popup"></span> </div> 
     </div> 
    </div> 
    <div class="field-group resetable"> 
     <label for="comment-popup">Description</label> 
     <textarea id="comment-popup" name="comment" class="tempo-comment textarea resetable"></textarea> 
    </div> 
    <ul id="errors-popup" class="error-list"> </ul> 
    <p style="width: 97%; margin: 0 0 10px 0;" id="tempo-logwork-issue-hint" class="hint-container overflow-ellipsis" title="Pressing w also opens this dialog box"> <a class="shortcut-tip-trigger" title="Click to view all shortcuts" href="#" tabindex="-1">Shortcut tip:</a> Pressing <strong>w</strong> also opens this dialog box </p> 
</div> 
<div class="buttons-container form-footer"> <span id="logwork-spinner" class="aui-icon aui-icon-wait" style="display:none"></span> 
    <div class="buttons"><span class="icon throbber"></span> 
     <input type="checkbox" id="issue-add-another" class="tempo-add-another-input" value="Another"> 
     <label for="issue-add-another" class="tempo-add-another-label"> Log another </label> 
     <input type="submit" id="issue-add-button" class="button button-panel-button" accesskey="s" value="Log Work"> <a id="tempo-logwork-issue-cancel" class="cancel" href="/jira/browse/AB-5048?" accesskey="'">Cancel</a> </div> 
</div> 

答えて

0

が見えるすべてのためのアドバイスで

感謝は、私が書いたもの

コードを助けます製品スイート。

だから、あなたはサファリIのものを除くすべての最新ブラウザで実行可能である必要属性 を追加することができますHTMLフィールド必須に属性を追加する

にJS(jqueryのを)これをチェックしてください

だろう
$('#comment-popup').attr('required', 'required'); 

それはAUI選択またはAUIの入力は、例えば選択にそこドキュメント https://docs.atlassian.com/aui/latest/docs/single-select.htmlを読んでいる場合、空でない属性

があります
関連する問題