Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

basicplaceholder

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basicplaceholder

Easy-to-use persistent placeholders for input fields

  • 1.4.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

basicPlaceholder

Easy-to-use persistent placeholders for input fields. Try it live on CodePen.

basicPlaceholder Screenshot

About

basicPlaceholder adds a label to the right side of an input when the original placeholder isn't visible. This is the case when the user enters text or when the value attribute of the input contains text.

basicPlaceholder is written in Vanilla JS and works in all modern browsers.

Features

  • Works in all modern browsers
  • Written in Vanilla JS
  • CommonJS and AMD support

Installation

We recommend to install basicPlaceholder using Bower or npm.

bower install basicPlaceholder
npm install basicplaceholder

Requirements

basicPlaceholder depends on the following browser APIs:

All of these APIs are capable of being polyfilled in older browsers. Check the linked resources above to determine if you must polyfill to achieve your desired level of browser support.

Usage

Include the CSS file in the head tag and the JS file at the end of your body tag:

<link rel="stylesheet" href="dist/basicPlaceholder.min.css">
<script src="dist/basicPlaceholder.min.js"></script>

Add inputs to your website and wrap div elements with the class basicPlaceholder around them:

<div class="basicPlaceholder">
    <input type="text" placeholder="Placeholder" value="">
</div>

Init basicPlaceholder with the following command:

var inputs = document.querySelectorAll('.basicPlaceholder input')

basicPlaceholder.init(inputs)

Custom text

The value of the label is based on the placeholder attribute of the associated input. You can customize the text by adding a data-basicPlaceholder-text attribute to the input.

<div class="basicPlaceholder">
    <input type="text" placeholder="Placeholder" value="" data-basicPlaceholder-text="Custom">
</div>

Persistent label

Add the data-basicPlaceholder-persistent attribute to make the label persistent. It will stay on the right side of the input no matter what happens.

<div class="basicPlaceholder">
    <input type="text" value="" data-basicPlaceholder-persistent data-basicPlaceholder-text="Persistent">
</div>

Error label (Red)

<div class="basicPlaceholder">
    <input type="text" value="" placeholder="Error" data-basicPlaceholder-error>
</div>

Warning label (Yellow)

<div class="basicPlaceholder">
    <input type="text" value="" placeholder="Warning" data-basicPlaceholder-warning>
</div>

Keywords

FAQs

Package last updated on 08 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc