3.0 KiB
3.0 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d778b367417b2b2512aa8 | Add an Accessible Date Picker | 0 | 添加无障碍日期选择器 |
Description
input
字段,可用于创建多个不同的表单控件。此元素的type
属性指示将创建哪种输入。您可能已经注意到text
并在先前的挑战中submit
输入类型,HTML5引入了一个指定date
字段的选项。根据浏览器支持,当日期选择器处于焦点时,它会在input
字段中显示,这使得所有用户都可以更轻松地填写表单。对于旧版浏览器,该类型将默认为text
,因此有助于向用户显示标签中的预期日期格式或以及占位符文本以防万一。这是一个例子: <label for =“input1”>输入日期:</ label>
<input type =“date”id =“input1”name =“input1”>
Instructions
input
标记,其type
属性为“date”, id
属性为“pickdate”, name
属性为“date”。 Tests
tests:
- text: 您的代码应为日期选择器字段添加一个<code>input</code>标记。
testString: 'assert($("input").length == 2, "Your code should add one <code>input</code> tag for the date selector field.");'
- text: 您的<code>input</code>标记应具有值为date的<code>type</code>属性。
testString: 'assert($("input").attr("type") == "date", "Your <code>input</code> tag should have a <code>type</code> attribute with a value of date.");'
- text: 您的<code>input</code>标记应具有值为pickdate的<code>id</code>属性。
testString: 'assert($("input").attr("id") == "pickdate", "Your <code>input</code> tag should have an <code>id</code> attribute with a value of pickdate.");'
- text: 您的<code>input</code>标记应具有值为date的<code>name</code>属性。
testString: 'assert($("input").attr("name") == "date", "Your <code>input</code> tag should have a <code>name</code> attribute with a value of date.");'
Challenge Seed
<body>
<header>
<h1>Tournaments</h1>
</header>
<main>
<section>
<h2>Mortal Kombat Tournament Survey</h2>
<form>
<p>Tell us the best date for the competition</p>
<label for="pickdate">Preferred Date:</label>
<!-- Add your code below this line -->
<!-- Add your code above this line -->
<input type="submit" name="submit" value="Submit">
</form>
</section>
</main>
<footer>© 2018 Camper Cat</footer>
</body>
Solution
// solution required