Pen Settings

HTML

CSS

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

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

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.

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

              
                <div class="mainContainer">
	<p class="readmoreBlock"><span>readmore...</span></p>
	<div class="container readContent">
		<div class="feaBlock">
			<h2>Custom Select box jquery plugin.</h2>
			<p>The purpose of this simple form validation is to check custom selectbox jquery plugin.</p>
			<h4 class="feaTabBtn"><span>Custom selectbox Features: </span><small>show</small></h4>
			<ul class="feaTabCon">
				<li>1. Up & Down key works to select list item.</li>
				<li>2. Enter works to select the item from list.</li>
				<li>3. Mouse click works to select the list item.</li>
				<li>4. Scrollbar hide, but you can scroll the selectbox list items later (working on it).</li>
			</ul>
			<div class="noteBlock"><b>Note:</b><span>Your input values don't track. <i>\0/</i></span><u>View it in codepen fullpage.</u></div>
		</div>
	</div>
	
	<div class="container">
		<form name="registerForm" class="formBlock">
			<h2 class="formTitle">Register form</h2>
			<div>
				<label>Name:</label>
				<input type="text" id="name" placeholder="Name" autocomplete="off"/>
			</div>
			<div>
				<label>Password:</label>
				<input type="password" id="password" placeholder="Password"/>
			</div>
			<div>
				<label>Email:</label>
				<input type="email" id="email" placeholder="Email" autocomplete="off"/>
			</div>
			<div>
				<label>Country:</label>
				<select name="" id="cusSelectbox">
					<option value="select">select</option>
					<option value="india">india</option>
					<option value="nepal">nepal</option>
					<option value="bangladesh">bangladesh</option>
					<option value="sri lanka">sri lanka</option>
					<option value="pakistan">pakistan</option>
				</select>
			</div>
			<div class="btnBlock">
				<button type="submit" onclick="return validateRegister();" class="btn">Submit</button>
			</div>
			<div class="errorBlock">
				<p id="regisErr"></p>
			</div>
		</form>
	</div>
</div>
              
            
!

CSS

              
                /* font-face */
@import url(https://fonts.googleapis.com/css?family=Roboto);
/* variables */
/* default style */
body {
  background-color: #fff;
  color: #333;
  font-family: "Roboto", arial, sans-serif;
  font-size: 16px;
}
/* common style */
* {
  margin: 0;
  padding: 0;
}
*,
*:after,
*:before {
  box-sizing: border-box;
}
::-webkit-scrollbar { 
  display: none; 
}
/* */
.mainContainer {
	margin: 0 auto;
	width: 600px;
}
.container {
	text-align: center;
	&:last-child {
		border-top: 2px dashed #333;
	}
}
.selected-item {
  margin: 20px 0;
}
/* custom select style */
.cusSelBlock {
  height: 50px;
  min-width: 250px;
}
#cusSelectbox {
  height: 100%;
  width: 100%;
}
.s-hidden {
  visibility: hidden;
}
.cusSelBlock {
  display: inline-block;
  position: relative;
  -webkit-perspective: 800px;
          perspective: 800px;
}
.selectLabel {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 9999;

  background-color: #fff;
  border: 1px solid #333;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
  color: #333;
  cursor: pointer;
  display: block;

  height: 100%;
  width: 100%;

  letter-spacing: 2px;
  line-height: 50px;
  padding: 0 50px 0 20px;
  text-align: left;

  -webkit-transform-style: preserve-3d;
          transform-style: preserve-3d;
  -webkit-transform-origin: 50% 0%;
          transform-origin: 50% 0%;

  -webkit-transition: -webkit-transform 300ms;
  transition: -webkit-transform 300ms;
  transition: transform 300ms;
  transition: transform 300ms, -webkit-transform 300ms;

  -webkit-backface-visibility: hidden;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  &:after {
    content: '\25BC';
    border-left: 1px solid #333;
    color: #333;
    font-size: 12px;
    line-height: 17px;
    padding: 10px;
    text-align: center;

    position: absolute;
    right: 0px;
    top: 15%;

    height: 70%;
    width: 50px;
  }
  &:active {
    -webkit-transform: rotateX(30deg);
            transform: rotateX(30deg);
    &:after {
      content: '\25B2';
    }
  }
  &.active {
    &:after {
      content: '\25B2';
    }
    &+.options {
      //height: 200px;
      //overflow-y: auto;
    }
  }
}
.options {
  position: absolute;
  top: 50px;

  height: 1px;
  width: 100%;
  li {
    background-color: rgba(255,255,255,1);
    border-left: 1px solid #333;
    border-right: 1px solid #333;
    border-bottom: 1px solid #333;
    cursor: pointer;
    display: block;
    line-height: 50px;
    list-style: none;
    opacity: 1;
    padding: 0 50px 0 20px;
    text-align: left;

    -webkit-transition: -webkit-transform 300ms ease;
    transition: -webkit-transform 300ms ease;
    transition: transform 300ms ease;
    transition: transform 300ms ease, -webkit-transform 300ms ease;

    position: absolute;
    top: -50px;
    left: 0;
    z-index: 0;

    height: 50px;
    width: 100%;
    &:hover, &.active {
      background-color: #333;
      color: #fff;
    }
    &:nth-child(1) {
      -webkit-transform: translateY(2px);
      transform: translateY(2px);
      z-index: 6;
    }
    &:nth-child(2) {
      -webkit-transform: translateY(4px);
      transform: translateY(4px);
      z-index: 5;
    }
    &:nth-child(3) {
      z-index: 4;
    }
    &:nth-child(4) {
      z-index: 3;
    }
    &:nth-child(5) {
      z-index: 2;
    }
    &:nth-child(6) {
      z-index: 1;
    }
  }
}

/* form style */
.formTitle {
	font-size: 20px;
	font-weight: normal;
	margin-bottom: 20px;
	text-align: center;
	text-transform: capitalize;
	text-decoration: underline;
}
* {
	outline: none;
}
.formBlock {
	color: #111;
	margin: 0 auto;
	padding: 20px 0;
	text-align: left;
	width: 320px;
	> div {
		margin-bottom: 15px;
		&.btnBlock {
			margin: 30px 0 0;
		}
	}
	label {
		display: block;
		font-size: 17px;
		margin-bottom: 5px;
	}
}
.selectLabel {
	font-size: 17px;
	text-transform: capitalize;
	li {
		font-size: 17px;
	}
	&:focus {
		border-color: blue !important;
	}
}
.options {
	li {
		text-transform: capitalize;
	}
}
input {
	border: 1px solid #333;
	font-size: 17px;
	padding: 0 50px 0 20px;
	height: 50px;
	width: 100%;
	&:focus {
		border-color: blue;
	}
}
select {
	min-width: 320px;
}
.btn {
	border: 1px solid #333;
	border-radius: 0;
	background-color: #fff;
	color: #333;
	font-size: 17px;
	padding: 12px 20px;
	&:hover {
		background-color: #222;
		color: #fff;
	}
}
.errorBlock {
	margin: 20px 0 0;
	text-align: center;
}
.error, .success {
	font-size: 14px;
}
.error {
	border: 1px dashed red;
	color: red;
	padding: 5px 10px;
}
.success {
	border: 1px dashed green;
	color: green;
	padding: 5px 10px;
}

/**/
.feaBlock {
	margin: 20px 0;
	padding-left: 35px;
	text-align: left;
	h2 {
		margin-bottom: 20px;
		text-align: center;
	}
	h4 {
		font-size: 18px;
		font-weight: normal;
		margin: 10px 0;
		small {
			animation: blinkText 1s 10;
			cursor: pointer;
			display: inline-block;
			font-size: 16px;
		}
	}
	p {
		margin: 15px 0;
		text-indent: 40px;
	}
	ul {
		list-style: none;
	}
}
.noteBlock {
	margin: 15px 0;
	b, span, u {
		display: inline-block;
	}
	b {
		color: red;
		margin-right: 5px;
	}
	i {
		font-weight: bold;
		color: green;
	}
	u {
		margin-left: 10px;
	}
}
.feaTabCon, .readContent {
	display: none;
	&.active {
		animation: slideDown 1s;
		display: block;
	}
}
.readmoreBlock {
	margin: 15px 0;
	text-align: center;
	span {
		animation: blinkText 1s 10;
		cursor: pointer;
		font-size: 16px;
	}
}
@keyframes blinkText {
	0% { color: black; }
	30% { color: orange; }
	60% { color: purple; }
	90% { color: green; }
	100% { color: black; }
}
@keyframes slideDown {
	from { opacity: 0; }
	to { opacity: 1; }
}
              
            
!

JS

              
                $(function () {

	var defaultselectbox = $('#cusSelectbox');
	var numOfOptions = $('#cusSelectbox').children('option').length;

	// hide select tag
	defaultselectbox.addClass('s-hidden');

	// wrapping default selectbox into custom select block
	defaultselectbox.wrap('<div class="cusSelBlock"></div>');

	// creating custom select div
	defaultselectbox.after('<div class="selectLabel"></div>');

	// getting default select box selected value
	$('.selectLabel').text(defaultselectbox.children('option').eq(0).text());

	// appending options to custom un-ordered list tag
	var cusList = $('<ul/>', { 'class': 'options'} ).insertAfter($('.selectLabel'));

	// generating custom list items
	for(var i=0; i< numOfOptions; i++) {
		$('<li/>', {
		text: defaultselectbox.children('option').eq(i).text(),
		rel: defaultselectbox.children('option').eq(i).val()
		}).appendTo(cusList);
	}

	// open-list and close-list items functions
	function openList() {
		for(var i=0; i< numOfOptions; i++) {
			$('.options').children('li').eq(i).attr('tabindex', i).css(
				'transform', 'translateY('+(i*100+100)+'%)').css(
				'transition-delay', i*30+'ms');
		}
	}

	function closeList() {
		for(var i=0; i< numOfOptions; i++) {
			$('.options').children('li').eq(i).css(
				'transform', 'translateY('+i*0+'px)').css('transition-delay', i*0+'ms');
		}
		$('.options').children('li').eq(1).css('transform', 'translateY('+2+'px)');
		$('.options').children('li').eq(2).css('transform', 'translateY('+4+'px)');
	}

	// click event functions
	$('.selectLabel').click(function () {
		$(this).toggleClass('active');
		if( $(this).hasClass('active') ) {
			openList();
			focusItems();
		}
		else {
			closeList();
		}
	});

	$(".options li").on('keypress click', function(e) {
		e.preventDefault();
		$('.options li').siblings().removeClass();
		closeList();
		$('.selectLabel').removeClass('active');
		$('.selectLabel').text($(this).text());
		defaultselectbox.val($(this).text());
		$('.selected-item p span').text($('.selectLabel').text());
	});
	
});

function focusItems() {

	$('.options').on('focus', 'li', function() {
		$this = $(this);
		$this.addClass('active').siblings().removeClass();
	}).on('keydown', 'li', function(e) {
		$this = $(this);
		if (e.keyCode == 40) {
			$this.next().focus();
			return false;
		} else if (e.keyCode == 38) {
			$this.prev().focus();
			return false;
		}
	}).find('li').first().focus();

}

// features tab
$('.feaTabBtn small').click(function() {
	$('.feaTabCon').toggleClass('active');
	if($('.feaTabCon').hasClass('active')) {
		$(this).text('hide');
	}
	else {
		$(this).text('show');
	}
});
$('.readmoreBlock span').click(function() {
	$('.readContent').toggleClass('active');
	if($('.readContent').hasClass('active')) {
		$(this).text('lessmore...');
	}
	else {
		$(this).text('readmore...');
	}
});

// form validation
function validateRegister() {
	var emaidid, atpos, dotpos, password, username, country;

	username = $('#name').val();
	password = $('#password').val();
	emailid = $('#email').val();
	atpos = emailid.indexOf('@');
	dotpos = emailid.lastIndexOf('.');

	if (username == null || username == '') {
	$('#regisErr').addClass('error').text('* Name do not empty !');
	$('#name').focus();
	return false;
	}
	if(username.length < 6 ) {
	$('#regisErr').addClass('error').text('* Name should be min 6 char !');
	$('#name').focus();
	return false;
	}
	if(password == null || password == '') {
	$('#regisErr').addClass('error').text('* Password do not empty!');
	$('#password').focus();
	return false;
	}
	if(password.length < 6 ) {
	$('#regisErr').addClass('error').text('* Password do not short!');
	$('#password').focus();
	return false;
	}
	if(emailid == null || emailid == '') {
	$('#regisErr').addClass('error').text('* Email id do not empty!');
	$('#email').focus();
	return false;
	}
	if(atpos < 1 || dotpos < atpos+2 || dotpos+2 >= emailid.length) {
	$('#regisErr').addClass('error').text('It is not a valid email address!');
	$('#email').focus();
	return false;
	}

	country = $('.selectLabel').text();

	if (country == 'select') {
	$('#regisErr').removeClass('success').addClass('error').text('* Select country !');
	$('.selectLabel').focus();
	return false;
	}
	else if(country != 'select') {
	$('#regisErr').addClass('success').text('Your country is: '+country);
	return false;
	}
}
              
            
!
999px

Console