Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

Erstelle deinen eigenen Passwort-Generator in jQuery.

Die detaillierte Erklärung zum Skript findest du auf Codepalm:

<div id="password_generator">
		<input type="number" id="length" name="length" value="16" placeholder="Länge des Passworts" />
		<input type="checkbox" id="low_characters" name="low_characters" checked value="on" /><label for="low_characters">Lowercase Characters</label>
		<input type="checkbox" id="upper_characters" name="upper_characters" checked value="on" /><label for="upper_characters">Uppercase Characters</label>
		<input type="checkbox" id="number_characters" name="number_characters" checked value="on" /><label for="number_characters">Numbers</label>
		<input type="checkbox" id="special_characters" name="special_characters" checked value="on" /><label for="special_characters">Special Characters</label>
		<input type="text" id="pw_output" name="pw_output" value="" placeholder="Passwort" readonly />
		<input type="button" id="generate_pw" name="generate_pw" value="Passwort generieren" />
              /* Styles sind optional und können nach belieben angepasst werden */
body {
  font-family: Arial, sans-serif;
  font-size: 16px;
  text-align: center;

input {
  display: inline-block;
  font-size: 16px;
  padding: 8px;
  width: 200px;
input[type="checkbox"] + label {
  width: 180px;
  padding-right: 12px;
  margin: 10px 0;
  display: inline-block;
  cursor: pointer;
  text-align: left;

input[type="button"] {
  width: 220px;
  margin-top: 10px;
  display: inline-block;
  border: 1px solid #0096ff;
  background-color: #0096ff;
  color: #ffffff;
  padding: 8px 16px;
  transition: background-color .5s, color .5s;
input[type="button"]:hover {
  background-color: transparent;
  color: #0096ff;
  cursor: pointer;
              (function($) {
	$( document ).ready( function() {
		$( '#generate_pw' ).unbind( 'click' );
		$( '#generate_pw' ).bind( 'click', function() {
		function generate_password() {
			var characters = 'abcdefghijklmnopqrstuvwxyz';
			var special = '|<>#+*~-_!?§$%&/()=@';
			var numbers = '0123456789';
			var length = $( '#length' ).val();
			var special_on = $( '#special_characters' ).prop( 'checked' );
			var number_on = $( '#number_characters' ).prop( 'checked' );
			var uppercase_on = $( '#upper_characters' ).prop( 'checked' );
			var lowercase_on = $( '#low_characters' ).prop( 'checked' );
			var result = '';
			if( special_on )
				for( var i=0; i < Math.ceil( length/8 ); i++ )
					result += special;
			if( number_on )
				for( var i=0; i < Math.ceil( length/5 ); i++ )
					result += numbers;
			if( uppercase_on )
				for( var i=0; i < Math.ceil( length/8 ); i++ )
					result += characters.toUpperCase();
			if( lowercase_on )
				for( var i=0; i < Math.ceil( length/8 ); i++ )
					result += characters.toLowerCase();
			result = result.shuffle().slice( 0, length );
			$( '#pw_output' ).val( result ).select();
		// Diese Erweiterung des Strings werden wir später beim Generieren eines Passworts benötigen. Durch die shuffle-Funktion wird ein vorhandener String gemischt
		String.prototype.shuffle = function() {
			var chars = this.split( "" );
			var length = chars.length;
			for( var i = length-1; i > 0; i-- ) {
				var j = Math.floor( Math.random() * ( i + 1 ) );
				var tmp = chars[ i ];
				chars[ i ] = chars[ j ];
				chars[ j ] = tmp;
			return chars.join( "" );
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.