Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Load modernizr
- window.Modernizr=function(a,b,c){function A(){e.input=function(a){for(var b=0,c=a.length;b<c;b++)q[a[b]]=a[b]in k;return q}("autocomplete autofocus list placeholder max min multiple pattern required step".split(" ")),e.inputtypes=function(a){for(var d=0,e,g,h,i=a.length;d<i;d++)k.setAttribute("type",g=a[d]),e=k.type!=="text",e&&(k.value=l,k.style.cssText="position:absolute;visibility:hidden;",/^range$/.test(g)&&k.style.WebkitAppearance!==c?(f.appendChild(k),h=b.defaultView,e=h.getComputedStyle&&h.getComputedStyle(k,null).WebkitAppearance!=="textfield"&&k.offsetHeight!==0,f.removeChild(k)):/^(search|tel)$/.test(g)||(/^(url|email)$/.test(g)?e=k.checkValidity&&k.checkValidity()===!1:/^color$/.test(g)?(f.appendChild(k),f.offsetWidth,e=k.value!=l,f.removeChild(k)):e=k.value!=l)),p[a[d]]=!!e;return p}("search tel url email datetime date month week time datetime-local number range color".split(" "))}function z(a,b){return!!~(""+a).indexOf(b)}function y(a,b){return typeof a===b}function x(a,b){return w(prefixes.join(a+";")+(b||""))}function w(a){j.cssText=a}var d="2.0.6",e={},f=b.documentElement,g=b.head||b.getElementsByTagName("head")[0],h="modernizr",i=b.createElement(h),j=i.style,k=b.createElement("input"),l=":)",m=Object.prototype.toString,n="Webkit Moz O ms Khtml".split(" "),o={},p={},q={},r=[],s=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=y(e[d],"function"),y(e[d],c)||(e[d]=c),e.removeAttribute(d))),e=null;return f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),t,u={}.hasOwnProperty,v;!y(u,c)&&!y(u.call,c)?v=function(a,b){return u.call(a,b)}:v=function(a,b){return b in a&&y(a.constructor.prototype[b],c)};for(var B in o)v(o,B)&&(t=B.toLowerCase(),e[t]=o[B](),r.push((e[t]?"":"no-")+t));e.input||A(),w(""),i=k=null,e._version=d,e._domPrefixes=n,e.hasEvent=s;return e}(this,this.document);
- // If placeholders are not supported
- if(!Modernizr.input.placeholder)
- {
- // Loop through all inputs...
- $("input").each(function()
- {
- // ... with placeholders
- if($(this).val() == ""
- && $(this).attr("placeholder") != "")
- {
- // Put the placeholder as the value
- $(this).val($(this).attr("placeholder"));
- // Assign onFocus and onBlur events
- $(this).focus(function()
- {
- // If value is equal to the placeholder clear field
- if($(this).val() == $(this).attr("placeholder")) $(this).val("");
- });
- $(this).blur(function()
- {
- // If value is equal to the placeholder clear field
- if($(this).val() == "") $(this).val($(this).attr("placeholder"));
- });
- }
- });
- }
Add Comment
Please, Sign In to add comment