Accessibility in EJ2 JavaScript Numerictextbox control
24 Jan 20246 minutes to read
The Numerictextbox component followed the accessibility guidelines and standards, including ADA, Section 508, WCAG 2.2 standards, and WCAG roles that are commonly used to evaluate accessibility.
The accessibility compliance for the Numerictextbox component is outlined below.
WAI-ARIA attributes
The NumericTextBox characterized with complete ARIA Accessibility support which helps to accessible by on-screen readers and other assistive technology devices. This component designed with the reference of the guidelines document given in WAI ARAI Accessibility practices.
The NumericTextBox uses the spinbutton
role and following ARIA properties to its element based on its state.
Property | Functionality |
---|---|
aria-live | The aria-live attribute indicates the priority of updates to a live region |
aria-valuemin | The aria-valuemin property specifies the minimum allowable range of the NumericTextBox. |
aria-valuemax | The aria-valuemax property specifies the maximum allowable range of the NumericTextBox. |
aria-disabled | The aria-disabled property indicates disabled state of the NumericTextBox. |
aria-readonly | The aria-readonly property indicates the read-only state of the NumericTextBox. |
aria-valuenow | The aria-valuenow property specifies the current value of the NumericTextBox. |
aria-invalid | The aria-invalid property indicates that the user input is incorrect or not within acceptable ranges. |
aria-label | The aria-label property indicates a string value that labels the NumericTextBox. |
Keyboard interaction
Keyboard interaction of the NumericTextBox component has been designed based on
WAI-ARIA Practices described for the NumericTextBox and
it is an alternative to mouse actions to interact with the NumericTextBox.
The below table shows shortcut keys and its corresponding usage.
Keyboard shortcuts | Actions |
---|---|
Arrow Down | Increments the value. |
Arrow Up | Decrements the value |
// initializes NumericTextBox component
var numeric = new ej.inputs.NumericTextBox({
// sets value to the NumericTextBox
value: 10
});
// renders initialized NumericTextBox
numeric.appendTo('#numeric');
<!DOCTYPE html><html lang="en"><head>
<title>EJ2 NumericTextBox</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="TypeScript NumericTextBox Component">
<meta name="author" content="Syncfusion">
<link href="styles.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/28.1.33/ej2-base/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/28.1.33/ej2-inputs/styles/material.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/28.1.33/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div class="wrap">
<input id="numeric" type="text">
</div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
#container {
visibility: hidden;
}
#loader {
color: #008cff;
font-family: 'Helvetica Neue','calibiri';
font-size: 14px;
height: 40px;
left: 45%;
position: absolute;
top: 45%;
width: 30%;
}
.wrap {
margin: 0 auto;
width: 240px;
padding-top:100px;
}
Ensuring accessibility
The NumericTextBox component’s accessibility levels are ensured through an accessibility-checker and axe-core software tools during automated testing.
The accessibility compliance of the NumericTextBox component is shown in the following sample. Open the sample in a new window to evaluate the accessibility of the NumericTextBox component with accessibility tools.