freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/applied-accessibility/add-an-accessible-date-pick...

3.0 KiB
Raw Blame History

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

Camper Cat正在举办一场真人快打比赛并想让他的竞争对手看看哪个日期效果最佳。添加一个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>&copy; 2018 Camper Cat</footer>
</body>

Solution

// solution required