-
Notifications
You must be signed in to change notification settings - Fork 8
/
placeMe.min.js
1 lines (1 loc) · 1.24 KB
/
placeMe.min.js
1
$(function(){function supports_input_placeholder(){var i=document.createElement("input");return"placeholder"in i}if(supports_input_placeholder()){}else{var $placeholder=$("[placeholder]");$placeholder.each(function(){var $this=$(this),val=$this.attr("placeholder");if($this.attr("type")=="password"){var x=$this.position().left,y=$this.position().top,eClass=$this.attr("class")?$this.attr("class"):"",id=$this.attr("id")?$this.attr("id"):"",parent=$this.parent(),el='<input type="text" id="'+id+'" class="'+eClass+' placePass" value="'+val+'" style="position: absolute; top: '+y+"px; left: "+x+'px; z-index: 9999;">';$(parent).prepend(el)}if($this.val()==""&&$this.attr("type")!="password"){$this.val(val)}});$(".placePass").focus(function(){$(this).hide()});$placeholder.focus(function(){var $this=$(this),value=$this.val(),placeholderTxt=$this.attr("placeholder");if(value==placeholderTxt){$this.val("")}});$placeholder.blur(function(){var $this=$(this),value=$this.val(),placeholderTxt=$this.attr("placeholder");if(value==""&&$this.attr("type")!="password"){$this.val(placeholderTxt)}});$("form").submit(function(){var $this=$(this),$input=$this.find(":input");$input.each(function(){var $this=$(this);if($this.val()==$this.attr("placeholder")){$this.val("")}})})}});