Friday, October 13, 2017

Change style of textarea based on checkbox

I would like to change the style of a textarea if a checkbox is checked and the textarea is empty. A red border should appear.

If the textarea is not empty and the checkbox is not checked, the border should disappear.

I have tried something like this, but the border is shown even when the textarea is not empty.

<input style="display: inline;" id="checkbox1" type="checkbox" ng-model="checked">

<textarea name="" id="" cols="5" rows="3" ng-model="comments" ng-disabled="request.disableTransfer" ng-pattern="/^[0-9A-Za-z]*$/" ng-required="checked"></textarea>

This is the css part :

textarea.ng-invalid {
    border: 3px solid #cc4b37 !important;
}

Source: AngularJS



from Angular Questions https://angularquestions.com/2017/10/13/change-style-of-textarea-based-on-checkbox/
via @lzomedia #developer #freelance #web #lzomedia.com

No comments:

Post a Comment