我想在调用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)