Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <main class="container" lang="ja">

<form id="passwordForm" class="mt-5">
<div class="col-lg-6 col-md-8">
<label class="form-label" for="passwordInput">パスワード (必須)</label>
<div class="input-group">
<input type="password" class="form-control border-dark rounded-0" id="passwordInput" required>
<div class="input-group-append" aria-live="polite" aria-relevant="text">
<button type="button" class="btn btn-secondary rounded-0" id="toggleButton" hidden>表示する</button>
</div><!-- end .input-group-append -->
</div><!-- end .input-group -->
<div id="passwordDisplay" class="px-2" hidden></div>
</div><!-- end .col-lg-6 .col-md-8 -->
<div role="status" id="passwordDisplayNotice" class="visually-hidden">
</div>


<button type="submit" class="btn btn-primary rounded-0 mt-5">送信</button>
</form>

</main>
              
            
!

CSS

              
                #passwordDisplay {
    display:none;
    line-break:anywhere;
    background-color:#ececec;
}

              
            
!

JS

              
                const passwordForm = document.getElementById('passwordForm');
const passwordInput = document.getElementById('passwordInput');
const toggleButton = document.getElementById('toggleButton');
const passwordDisplay = document.getElementById('passwordDisplay');
const passwordDisplayNotice = document.getElementById('passwordDisplayNotice');
const browser = window.navigator.userAgent.toLowerCase();

// JavaScript 有効時、もし Edge でなければ、トグルボタンとパスワード表示エリアを提示する。
if (browser.indexOf("edg") === -1) {
toggleButton.removeAttribute("hidden");
passwordDisplay.removeAttribute("hidden");
}

// 
passwordInput.addEventListener('input', () => {
  const passwordValue = passwordInput.value;
  passwordDisplay.textContent = passwordValue;
});

toggleButton.addEventListener('click', () => {
    if (passwordDisplay.style.display === 'none') {
        passwordDisplay.style.display = 'block';
        toggleButton.textContent = '隠す';
        setTimeout(passwordDisplayNotice.textContent = 'パスワードの文字が、パスワード入力欄と「隠す」ボタンのすぐ下に、展開表示された状態です。', 2000);
    } else {
        passwordDisplay.style.display = 'none';
        toggleButton.textContent = '表示する';
        setTimeout(passwordDisplayNotice.textContent = 'パスワードの文字が、隠された状態です。', 2000);
    }
});

// フォームの送信時のダミー処理(送信した旨のアラートを表示)

passwordForm.addEventListener('submit', (event) => {
    event.preventDefault(); // フォームの実際の送信を防ぐ   
    alert('送信しました。');
});
              
            
!
999px

Console