I am tryi开发者_如何学JAVAng to use jQuery watermark and it's not working.
$(function () {
var watermark = "Enter Phone Number";
watermark.fontcolor = $(this).col
if ($("#txtPhone").val() == "") {
$("#txtPhone").val(watermark);
}
$("#txtPhone").focus(function () {
if (this.value == watermark) {
this.value = "";
}
}).blur(function () {
if (this.value == "") {
this.value = watermark;
}
});
});
The page is a contentPlaceHolder.
Anything wrong with this?
Your code works fine. Perhaps the problem is with your markup: are you sure that the <input>
tag has an id value "txtPhone" and not just a name ?
That line that tries to set the font color is not going to work as it stands, however. The value of this
is probably either undefined or else it's the "window" object.
Incase you still have problem with watermark plugin use this one http://www.tectual.com.au/posts/8/jQuery-Watermark-Plugin-Best-jQuery-Placeholder-.html. Here is a watermark sample page. It support all kinds of watermarking you need.
is your type number or something else(url, email, may be...)???
if yes, it should be changed to text.
<input type="text" />
not
<input type="number" /> or something else like (url, email)
精彩评论