2018-09-30 22:01:58 +00:00
|
|
|
---
|
|
|
|
id: bad87fee1348bd9aedf08830
|
|
|
|
title: Add Placeholder Text to a Text Field
|
|
|
|
challengeType: 0
|
|
|
|
videoUrl: 'https://scrimba.com/p/pVMPUv/cKdJDhg'
|
2019-07-31 18:32:23 +00:00
|
|
|
forumTopicId: 16647
|
2018-09-30 22:01:58 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
## Description
|
|
|
|
<section id='description'>
|
|
|
|
Placeholder text is what is displayed in your <code>input</code> element before your user has inputted anything.
|
|
|
|
You can create placeholder text like so:
|
2019-03-08 08:31:47 +00:00
|
|
|
<code><input type="text" placeholder="this is placeholder text"></code><br>
|
|
|
|
<strong>Note:</strong> Remember that <code>input</code> elements are self-closing.
|
2018-09-30 22:01:58 +00:00
|
|
|
</section>
|
|
|
|
|
|
|
|
## Instructions
|
|
|
|
<section id='instructions'>
|
|
|
|
Set the <code>placeholder</code> value of your text <code>input</code> to "cat photo URL".
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
```yml
|
2018-10-04 13:37:37 +00:00
|
|
|
tests:
|
2019-11-20 14:45:19 +00:00
|
|
|
- text: You should add a <code>placeholder</code> attribute to the existing text <code>input</code> element.
|
2019-07-02 23:30:12 +00:00
|
|
|
testString: assert($("input[placeholder]").length > 0);
|
2019-11-20 14:45:19 +00:00
|
|
|
- text: You should set the value of your placeholder attribute to "cat photo URL".
|
2019-07-02 23:30:12 +00:00
|
|
|
testString: assert($("input") && $("input").attr("placeholder") && $("input").attr("placeholder").match(/cat\s+photo\s+URL/gi));
|
|
|
|
- text: The finished <code>input</code> element should not have a closing tag.
|
|
|
|
testString: assert(!code.match(/<input.*\/?>.*<\/input>/gi));
|
2018-10-04 13:37:37 +00:00
|
|
|
- text: The finished <code>input</code> element should have valid syntax.
|
2019-07-02 23:30:12 +00:00
|
|
|
testString: assert($("input[type=text]").length > 0);
|
2018-09-30 22:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
<div id='html-seed'>
|
|
|
|
|
|
|
|
```html
|
|
|
|
<h2>CatPhotoApp</h2>
|
|
|
|
<main>
|
|
|
|
<p>Click here to view more <a href="#">cat photos</a>.</p>
|
2018-10-08 00:01:53 +00:00
|
|
|
|
2018-09-30 22:01:58 +00:00
|
|
|
<a href="#"><img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a>
|
2018-10-08 00:01:53 +00:00
|
|
|
|
2018-09-30 22:01:58 +00:00
|
|
|
<p>Things cats love:</p>
|
|
|
|
<ul>
|
|
|
|
<li>cat nip</li>
|
|
|
|
<li>laser pointers</li>
|
|
|
|
<li>lasagna</li>
|
|
|
|
</ul>
|
|
|
|
<p>Top 3 things cats hate:</p>
|
|
|
|
<ol>
|
|
|
|
<li>flea treatment</li>
|
|
|
|
<li>thunder</li>
|
|
|
|
<li>other cats</li>
|
|
|
|
</ol>
|
|
|
|
<input type="text">
|
|
|
|
</main>
|
|
|
|
```
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
<section id='solution'>
|
|
|
|
|
2019-04-22 06:07:05 +00:00
|
|
|
```html
|
|
|
|
<h2>CatPhotoApp</h2>
|
|
|
|
<main>
|
|
|
|
<p>Click here to view more <a href="#">cat photos</a>.</p>
|
|
|
|
|
|
|
|
<a href="#"><img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a>
|
|
|
|
|
|
|
|
<p>Things cats love:</p>
|
|
|
|
<ul>
|
|
|
|
<li>cat nip</li>
|
|
|
|
<li>laser pointers</li>
|
|
|
|
<li>lasagna</li>
|
|
|
|
</ul>
|
|
|
|
<p>Top 3 things cats hate:</p>
|
|
|
|
<ol>
|
|
|
|
<li>flea treatment</li>
|
|
|
|
<li>thunder</li>
|
|
|
|
<li>other cats</li>
|
|
|
|
</ol>
|
|
|
|
<input type="text" placeholder="cat photo URL">
|
|
|
|
</main>
|
2018-09-30 22:01:58 +00:00
|
|
|
```
|
2019-07-18 15:24:12 +00:00
|
|
|
|
2018-09-30 22:01:58 +00:00
|
|
|
</section>
|