Maurizio In ..
5
这很简单,我认为应该解决所有问题的解决方案:
这是您的提交按钮:
然后把这个小jQuery放在一个js文件中:
//this will submit only if the value is not default
$("#submitBtn").click(function () {
if ($("#valueText").val() === "ENTER VALUE")
{
alert("please insert a valid value");
return false;
}
});
//this will put default value if the field is empty
$("#valueText").blur(function () {
if(this.value == ''){
this.value = 'ENTER VALUE';
}
});
//this will empty the field is the value is the default one
$("#valueText").focus(function () {
if (this.value == 'ENTER VALUE') {
this.value = '';
}
});
它也适用于旧版浏览器.此外,如果您需要,它可以很容易地转换为普通的JavaScript.