如果选中复选框并且textarea为空,我想更改textarea的样式。应出现红色边框。
如果textarea不为空并且未选中复选框,则边框应消失。
我尝试过类似的东西,但即使textarea不为空,也会显示边框。
<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>
这是css部分:
textarea.ng-invalid {
border: 3px solid #cc4b37 !important;
}
答案 0 :(得分:1)
怎么样?
.invalid-input {
border: 3px solid #cc4b37 !important;
}
<textarea ng-class="{'invalid-input': (!comments || comments == '' )&& checked }" id="" cols="5" rows="3" ng-model="comments"
ng-disabled="request.disableTransfer" ng-pattern="/^[0-9A-Za-z]*$/" ng-required="checked"></textarea>
答案 1 :(得分:1)
它按照您的要求工作......
1。如果复选框已选中且文本区域为空。红色边框应显示。
2。如果textarea不是为空且复选框未选中,则边框应消失。
你能指出错误吗?
import itertools
from collections import Counter
image_info = [
{
"id" : "34694102243_3370955cf9_z",
"title" : "Eastern",
"flickr_user" : "Sean Davis",
"tags" : ["Los Angeles", "California", "building"]
},
{
"id" : "37198655640_b64940bd52_z",
"title" : "Spreetunnel",
"flickr_user" : "Jens-Olaf Walter",
"tags" : ["Berlin", "Germany", "tunnel", "ceiling"]
},
{
"id" : "34944112220_de5c2684e7_z",
"title" : "View from our rental",
"flickr_user" : "Doug Finney",
"tags" : ["Mexico", "ocean", "beach", "palm"]
},
{
"id" : "36140096743_df8ef41874_z",
"title" : "Someday",
"flickr_user" : "Thomas Hawk",
"tags" : ["Los Angeles", "Hollywood", "California", "Volkswagen", "Beatle", "car"]
}
]
my_counter = 0
search = "CAT IN BUILding california"
search = set(search.lower().split())
matches = {}
index = {}
# Building a rudimentary search index
for info in image_info:
bag = info["title"].lower().split(" ")
tags = [t.lower().split(" ") for t in info["tags"]] # we want to be able to hit "los angeles" as will as "los" and "angeles"
tags = list(itertools.chain.from_iterable(tags))
for k in (bag + tags):
if k in index:
index[k].append(info["id"])
else:
index[k] = [info["id"]]
#print(index)
hits = []
for s in search:
if s in index:
hits += index[s]
print(Counter(hits).most_common(1)[0][0])