小编Rah*_*ngh的帖子

如何使用javascript更改占位符的颜色?

我想在调用mobileValidate()后更改此占位符的颜色.

<input type="text" class="form-control" name="InputMobile" id="Mobile"    placeholder="Enter Mobile Number" onblur="mobileValidate()"required>
Run Code Online (Sandbox Code Playgroud)

JavaScript函数是

function mobileValidate(){

    var x = document.getElementById("Mobile");

        if ((x.value).match(re)){
            alert("mobile Number is valid");
        }
        else{

            alert("mobile no is not valid");
            x.value="";
            x.placeholder.style.color="red";
        }

}
Run Code Online (Sandbox Code Playgroud)

html javascript css

6
推荐指数
1
解决办法
4177
查看次数

标签 统计

css ×1

html ×1

javascript ×1