查了很多资料,最后没搞定,
干脆直接用jquery写了一个!唉!
用程序前,先引入jquery才能使用!




代码 复制 - 运行

        //电话input说明
        $("input[type='tel']").each(function (i, el) {
            el.type = "text";
            el.value=el.placeholder;
            el.onfocus = function () {
                el.type = "tel";
                if(el.value==el.placeholder){
                    el.value="";
                }
            };
            el.onblur = function () {
                el.type = "text";
                if(el.value==""){
                    el.value=el.placeholder;
                }
            };
        });
        //验证码input说明
        $("input[type='number']").each(function (i, el) {
            el.type = "text";
            el.value=el.placeholder;
            el.onfocus = function () {
                el.type = "number";
                if(el.value==el.placeholder){
                    el.value="";
                }
            };
            el.onblur = function () {
                el.type = "text";
                if(el.value==""){
                    el.value=el.placeholder;
                }
            };
        });
        //密码input说明
        $("input[type='password']").each(function (i, el) {
            el.type = "text";
            el.value=el.placeholder;
            el.onfocus = function () {
                el.type = "password";
                if(el.value==el.placeholder){
                    el.value="";
                }
            };
            el.onblur = function () {
                el.type = "text";
                if(el.value==""){
                    el.value=el.placeholder;
                }else{
                    el.type = "password";
                }
            };
        });