GithubHelp home page GithubHelp logo

placeholder.js's Introduction

PLACEHOLDER.JS

Build stylish forms with dynamic placeholders for improved user experience. You can find the placeholder.js file here, or use the CDN at: http://www.iamsamsmith.co/cdn/placeholder.js

Requirements

  • Make sure to include Jquery in your HTML file prior to placeholder.js.
  • Call the placeholder function inside $(document).ready(function(){...})
  • Remember to add any styling attributes within quotation marks.
  • The font-size of the placeholder is determined in accordance with the height of the input
  • The use of pixels for styling is recommended

Example

$(document).ready(function(){
	placeholder({
		container: "#formContainer", --> Can be a class, id or HTML tag selector
		inputs : [ --> an array of objects - each object creates its own input
			{
				placeholder: "Your Email", --> the text to use for this placeholder (leave blank for inputs which you don't want to have a placeholder)
				inputName: "email", --> Compulsory
				inputType: "email", --> type of input
				inputClass: "textInput", --> apply any classes for external styling
				inputId: "emailInput", --> as above
				inputStyle:{ --> an object containing any CSS styling for the input itself
					height: "30px" / "30" / 30, --> express pixel amounts in any format
					width: "200px",
					"margin-top": 30, --> be sure to place quotation marks around any hyphenated attributes
					outline: "none" --> nice to remove the blue outline on focus
				},
				placeholderStyle: { --> this object allows you to adjust placeholder style and positioning
					unfocusedTop: 0, --> move the placeholder down X pixels when not focused on input (use negative px for up)
					unfocusedLeft: 10, --> move the placeholder left X pixels when not focused on input (use negative px for left)
					focusedTop: 0, --> move the placeholder down X pixels when focused on input (use negative px for up)
					focusedLeft: 10, --> move the placeholder left X pixels when focused on input (use negative px for left)

					unfocusedColor: "blue", --> the color of placeholder text when not focused
					focusedColor: "green", --> the color of placeholder text when focused
					"font-family": "Arial"
				}
			},{...}
		],
		submitButton: { --> option to add a submit button
			submitButtonStyle: { --> style the button
				width: 200,
				"margin-top": 30,
				"font-size": 30
			},
			// submitButtonId: , --> add an id for external styling or event detection
			// submitButtonClass: , --> add a class for external styling
			onclick: function(event){ --> a method triggered by a click event on the button
				alert("click");
			}
		}
	})
})

placeholder.js's People

Contributors

54m5m17h avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.