我有一个文本字段,最多只能包含15个字符。我包括aria-label
来说“名字(最多15个字符)”。我也想在达到最大字符数时提醒用户,并且他们无法进一步输入。
执行此操作的最佳方法是什么?
屏幕阅读器似乎不支持maxlength
。
答案 0 :(得分:1)
很遗憾,您必须解决此问题。屏幕阅读器应遵守"""
GetActiveAccountLicenses
Retrieve the active account software licenses owned by an account.
Important manual pages:
https://softlayer.github.io/reference/services/SoftLayer_Account/getActiveAccountLicenses/
https://softlayer.github.io/reference/datatypes/SoftLayer_Software_AccountLicense/
License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""
import json
import SoftLayer
# For nice debug output:
from pprint import pprint as pp
# Your SoftLayer API username and key.
API_USERNAME = 'set me'
# Generate one at https://control.softlayer.com/account/users
API_KEY = 'set me'
objectMask = 'mask[billingItem[id,cancellationDate,orderItem[order[createDate]]],softwareDescription[name,manufacturer,' \
'virtualLicense]]'
objectFilter = {"activeAccountLicenses":{"softwareDescription":{"manufacturer":{"operation":"VMware"}}}}
client = SoftLayer.create_client_from_env(
username=API_USERNAME,
api_key=API_KEY
)
try:
accountLicenses = client['SoftLayer_Account'].getActiveAccountLicenses(mask=objectMask, filter= objectFilter)
print(json.dumps(accountLicenses, sort_keys=True, indent=2, separators=(',', ': ')))
except SoftLayer.SoftLayerAPIError as e:
pp('Unable to retrieve the account licenses faultCode=%s, faultString=%s'
% (e.faultCode, e.faultString))
属性并为您宣布限制,并定期告诉用户还剩下多少个字符。但是在标签中添加最大值是对所有用户的一种好习惯。
即使您达到了最大值,屏幕阅读器也会在输入时愉快地提供反馈。这很糟糕,我认为这是屏幕阅读软件中的错误。
由于您的字段只有15个字符,因此您可能不需要反馈,直到它们到达结尾为止。如果您有100个字符,则在更新的字段下方带有“剩余X个字符”标签,例如,每20次击键会有所帮助。
现在,您可以拥有一个aria-live
区域,当达到最大值时,您可以向其中注入文本,表明已达到限制,或者可以取消隐藏该活动区域的子DOM元素。无论哪种方式都将宣布文本。
{
"accountId": 11111,
"capacity": "4",
"key": "4ADFG-5GSDL-20FDF9-SFSD3-FSDF5",
"units": "CPU",
"billingItem": {
"cancellationDate": null,
"id": 22222,
"orderItem": {
"categoryCode": "software_license",
"description": "vCenter Server Appliance 6.0",
"id": 33333,
"recurringFee": "0",
"setupTaxAmount": "0",
"order": {
"createDate": "2018-03-13T05:30:26-06:00"
}
}
},
"softwareDescription": {
"manufacturer": "VMware",
"name": "vCenter"
}
},
或
maxlength