Styling input password in HTML

input type=password css
html password validation
input type=password asterisk
show password eye icon html
html length validation
css text-security
html password script
password pattern in html

I have an input type password that only allow a six-digit number like this:

<fieldset>
  <label for="password-input">Enter New Pin</label>
  <input type="password" name="password" id="password-input" inputmode="numeric" minlength="6"
  maxlength="6" size="6" value="">
  <span class="hint">New pin must be 6 digit number only</span>
</fieldset>

It will show like this:

How can I style it so it can look like the following?

HTML input type="password", of how to use HTML, CSS, JavaScript, SQL, PHP, Python, Bootstrap, Java and XML. The <input type="password"> defines a password field (characters are  The <input type="password"> defines a password field (characters are masked). Note: Any forms involving sensitive information like passwords should be served over HTTPS. Tip: Always add the <label> tag for best accessibility practices!

Try this:

input {
  padding-left: 15px;
  letter-spacing: 39px;
  border: 0;
  background-image: linear-gradient(to left, black 70%, rgba(255, 255, 255, 0) 0%);
  background-position: bottom;
  background-size: 50px 3px;
  background-repeat: repeat-x;
  background-position-x: 35px;
  width: 280px;
  font-size: 30px;
}

input:focus {
  outline: none;
}
<fieldset>
  <label for="password-input">Enter New Pin</label>
  <input type="password" name="password" id="password-input" inputmode="numeric" minlength="6" maxlength="6" size="6" value="">
  <span class="hint">New pin must be 6 digit number only</span>
</fieldset>

CSS Forms, The best I can find is to set input[type="password"] {font:small-caption;font-size:​16px}. Demo: http://jsfiddle.net/x5CCf/. If you only want to style a specific input type, you can use attribute selectors: input[type=text] - will only select text fields input[type=password] - will only select password fields input[type=number] - will only select number fields

Styling Password Fields in CSS, I didn't change the markup as <input type=password /> is perfectly valid. It doesn't change the type to text, it just doesn't let you change the styling. It's locked debug, and show off your HTML, CSS, and JavaScript creations. HTML input type password field - example code and techniques. The HTML <input type="password"> element is a specific type of input elements used to create input fields that deal with passwords . It is designed to deal with passwords so it’s more secure than the normal <input type='text'> we see in every form on the internet.

Better Password Inputs, iPhone Style, input[type="password"] { -webkit-text-security: disc !important;}. in the User Agent stylesheet. While you can overwrite CSS in your UA StyleSheet, you can't  Input Type Password In HTML: Here’s How To Obfuscate Password Entry Fields Disclosure: Your support helps keep the site running! We earn a referral fee for some of the services we recommend on this page.

This conventional solution may help for cross browser :

The HTML form :

<p class="text-center">Enter new pins</p>
     <form role="form" method="post">
        <div class="form-group text-center">

                <input class="inputbox"  maxlength="1" type="password" >
                <input class="inputbox"  maxlength="1" type="password" >
                <input class="inputbox"  maxlength="1" type="password" >
                <input class="inputbox"  maxlength="1" type="password" >
                <input class="inputbox"  maxlength="1" type="password" >
                <input class="inputbox"  maxlength="1" type="password" >

                <small class="text-danger">New pin must be 6 digit number only</small>      
            </div>

        <div class="form-group">
            <button type="submit" class="btn btn-primary btn-lg btn-block">Verify Pin
            </button>
        </div>
        <input id="code_hidden" maxlength="6" name="real_code" type="text" >
    </form>

We can see the result on input name = real_code. It must be type = 'hidden' on production. Change this maxlength when more field is required.

Style CSS :

<style>
.inputbox {
    background-color: #fff;
    border: none;
    border-bottom: thin solid gray;
    width: 20px;
    font-size: 24px;
    margin-bottom: 20px;
    margin-right: 5px;
}
</style>

Script part :

<script>
    $(function() {

    $(".inputbox").keyup(function () { 

        $(this).next('.inputbox').focus();

        var value = [];

        $('.inputbox').each(function() {
          value += $(this).val();  
        }); 

         $('#code_hidden').val(value); 
        });
    });

    </script>

Make Non-Password Inputs Use Bullets (or Bullet , create a password input field and style it; add a button that can enable the user to view his password in plain text; add validation to your password input field  Things sure have gotten easier than they were! The reason is that we can finally style the ::before and ::after pseudo-elements on the <input> tag itself. This means we can keep and style an <input> and won’t need any extra elements.

HTML5 Forms: Password Input Type, Use CSS instead. checked, Specifies whether a checkbox or radio button form input should be checked by default. disabled, Disables the input  Here are the different input types you can use in HTML: <input type="button">. <input type="checkbox">. <input type="color">. <input type="date">. <input type="datetime-local">. <input type="email">. <input type="file">. <input type="hidden">.

HTML input type password field, Password Form Styles that Chromium Understands your site's sign-up, sign-in and change-password forms by enriching your HTML with a dash of metadata. <input type="text" autocomplete="username"> <input type="password"  Login Form Signup Form Checkout Form Contact Form Social Login Form Register Form Form with Icons Newsletter Stacked Form Responsive Form Popup Form Inline Form Clear Input Field Hide Number Arrows Copy Text to Clipboard Animated Search Search Button Fullscreen Search Input Field in Navbar Login Form in Navbar Custom Checkbox/Radio Custom Select Toggle Switch Check Checkbox Detect Caps Lock Trigger Button on Enter Password Validation Toggle Password Visibility Multiple Step Form Autocomplete

Input Type Password In HTML: Here's How To Obfuscate Password , Note: We use the pattern attribute (with a regular expression) inside the password field to set a restriction for submitting the form: it must contain 8 or more characters that are of at least one number, and one uppercase and lowercase letter. Step 2) Add CSS: Style the input fields and the message box: /* Style all input fields */

Comments
  • We can't change the password masking character in input type password. We can do it for input type text but it has a security risk.
  • The fact that all of the answers below fail for at least one person should tell you not to attempt this.
  • similare question : stackoverflow.com/questions/49476209/…
  • I would go a different way. Use a single row, 6 cell table with background images and JavaScript/jQuery to process/mask/display. It will give you a lot more visual flexibility than trying to style a password input. It Is probably a lot more work but you can get everything to work and look exactly the way you want.
  • @SunKnight0 that would require to implement pasting from clipboard too for people with password managers.
  • @Ferrybig I set the font-family for input. Better?
  • @symlink the cursor is out of place for the last input
  • @blue That's expected; there's nothing that can be done about that really.
  • Width is wrong on Firefox - 5 characters get spread evenly over 6 underscores
  • Closer, but still off - by the 5th dot it's shifted to between the 5th and 6th underscores
  • the input font is too small, and when i enter the in put there is a blue border surrounding it, and when i enter the last character the input alignment become messy