当textarea变脏时更改按钮

时间:2014-09-18 13:41:45

标签: html css angularjs

当我编辑“textarea”时,我想让我的按钮改变颜色(或者能够接收其他订单)。它是纯CSS还是我的代码中还有一些东西需要修改?我自己找不到任何引用。

所以当“形式”变脏时,按钮会改变颜色 - (我不能上课或CSS)

此处我的 HTML:

<form name="formSignature" class="">
    <div>
      <i> Persönliche Signatur </i><br/>
      <textarea rows="5" cols="40" ng-model="newAccountSig" ng-trim="false" placeholder="{{user.signature}}">
      </textarea>
    </div>
    <div ng-hide="permissionExists('sign_change_global')">
    <i> Zweites Beispiel</i><br/>
    <textarea ng-readonly="true" rows="5" cols="40" ng-model="newCustomerSig" ng-trim="false" placeholder="{{user.customer.signature}}">
    </textarea>
    </div>

    <div ng-show="permissionExists('sign_change_global')">
      <i> Show this, when "sign_change_global" is in LIST</i><br/>
      <textarea rows="5" cols="40" ng-model="newCustomerSig" ng-trim="false" placeholder="{{user.customer.signature}}"></textarea>
    </div>
  </form>

应影响“表单”之外的按钮:

  <button type="submit" style="text-align:right; float:right"
           class="button green-button"
           ng-click="saveSignature()">Save</button>

我对表格进行了边界处理,作为对我的一点暗示。

enter image description here

1 个答案:

答案 0 :(得分:5)

尝试为textareas添加名称,例如:

<textarea rows="5" name="id1" cols="40" ng-model="newAccountSig" ng-trim="false" placeholder="{{user.signature}}">
  </textarea>

并将其放入按钮

ng-class="{' button green-button' : formSignature.id1.$pristine && formSignature.id2.$pristine && formSignature.id3.$pristine, 'button red-button' : !formSignature.id1.$pristine || !formSignature.id2.$pristine || !formSignature.id3.$pristine}"