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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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 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.

HTML

              
                <h3>郵便番号が <span>XXX-XXXX</span> ?</h3>
<div>
<p>郵便番号が <span>XXX-XXXX</span>で打ち込まれてるか<br>
判定するJavaScriptです!</p>
  </div>
<div class="cp_iptxt">
<input class="text" type="text" maxlength="8" placeholder="XXX-XXXXで入力後Enter">
<label>郵便番号</label>
<span class="focus_line"><i></i></span>
</div>
              
            
!

CSS

              
                .cp_iptxt {
	position: relative;
	width: 40%;
	margin: 40px 3%;
}
.cp_iptxt input[type='text'] {
	font: 15px/24px sans-serif;
	box-sizing: border-box;
	width: 100%;
	letter-spacing: 1px;
	padding-left: 4em;
}
.cp_iptxt input[type='text']:focus {
	outline: none;
}
.text {
	padding: 7px 14px;
	transition: 0.4s;
	border: 1px solid #1b2538;
	background: transparent;
  text-align:center;
}
.text ~ .focus_line:before,
.text ~ .focus_line:after {
	position: absolute;
	top: -1px;
	left: 50%;
	width: 0;
	height: 2px;
	content: '';
	transition: 0.4s;
	background-color: #da3c41;
}
.text ~ .focus_line:after {
	top: auto;
	bottom: 0;
}
.text ~ .focus_line i:before,
.text ~ .focus_line i:after {
	position: absolute;
	top: 50%;
	left: 0;
	width: 2px;
	height: 0;
	content: '';
	transition: 0.6s;
	background-color: #da3c41;
}
.text ~ .focus_line i:after {
	right: 0;
	left: auto;
}
.text:focus ~ .focus_line:before,
.text:focus ~ .focus_line:after,
.cp_iptxt.text ~ .focus_line:before,
.cp_iptxt.text ~ .focus_line:after {
	left: 0;
	width: 100%;
	transition: 0.4s;
}
.text:focus ~ .focus_line i:before,
.text:focus ~ .focus_line i:after,
.cp_iptxt.text ~ .focus_line i:before,
.cp_iptxt.text ~ .focus_line i:after {
	top: -1px;
	height: 100%;
	transition: 0.6s;
}
.text ~ label {
	position: absolute;
	z-index: -1;
	top: 10px;
	left: 14px;
	width: 100%;
	transition: 0.3s;
	letter-spacing: 0.5px;
	color: #aaaaaa;
}
.text:focus ~ label,
.cp_iptxt.text ~ label {
	font-size: 12px;
	top: -18px;
	left: 0;
	transition: 0.3s;
	color: #da3c41;
}
span{
  color:#27c1df;
}
              
            
!

JS

              
                $('.text').on('change',function(){
var zyuusyo0 = $('input.text').eq(0).val();
var zyuusyoXX = $('input.text').eq(0).length;

console.log(zyuusyoXX);
  
var kakunin1 = zyuusyo0.split('',8);
var a = kakunin1[0];
var b = kakunin1[1];
var c = kakunin1[2];
var d = kakunin1[3];
var e = kakunin1[4];
var f = kakunin1[5];
var g = kakunin1[6];
var h = kakunin1[7];
var zyuusyoXX = $(kakunin1).length;
console.log(zyuusyoXX);

var d = d.replace(kakunin1[3],'-');
console.log(a+b+c+d+e+f+g+h);
var zyuusyo1 = $('input.text').eq(0);
var zyuusyo2 =
    $(zyuusyo1).val().match(/^[-0-9]+$/);
if(zyuusyo0 === a+b+c+d+e+f+g+h){
window.alert('郵便番号が打ち込まれました!');
}else if(zyuusyo0 === zyuusyo2){
window.alert('郵便番号が打ち込まれました!');
}else{window.alert('値がおかしいです…');
$('input.text').eq(0).val('');
}
});
              
            
!
999px

Console