如何从Javascript将水印文本设置为文本框 [英] How to set the watermark text to the textbox from javascript

查看:92
本文介绍了如何从Javascript将水印文本设置为文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

if(!checkDate(document.getElementById("txtUPCDate").value) )
         {
        alert ( "Invalid Date" );
        document.getElementById("txtUPCDate").value="";
         setTimeout(function(){document.getElementById(''txtUPCDate'').focus()}, 5);
        return false;
        }



上面的编码是我在Form中使用的"Textbox1"的Javascript.该编码正常工作,但是如果我从DATABASE检索日期后将文本框设置为null.但是我想使用AJAX CONTROL将文本框文本设置为"DD/MM/YYYY".




The Above coding is the Javascript for "Textbox1" which i used in my Form . This coding is working Properly but if i make the textbox as null after retriving a date from DATABASE . But i want to make the textbox text as "DD/MM/YYYY" , for that textbox im using the AJAX CONTROL .


<asp:TextBox ID="txtUPCDate" runat="server" Text="DD/MM/YYYY" TabIndex="16" MaxLength="10" onchange="return UPCDateCheck();"></asp:TextBox>
     <ajaxToolkit:TextBoxWatermarkExtender ID=" TextBoxWatermarkExtender6" TargetControlID="txtUPCDate"
 WatermarkText="DD/MM/YYYY" runat="server">                                       </ajaxToolkit:TextBoxWatermarkExtender>                                      <ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender7" runat="server"                                              CultureName="en-GB" InputDirection="LeftToRight" Mask="99/99/9999"                                               MaskType="Date" TargetControlID="txtUPCDate">                                           </ajaxToolkit:MaskedEditExtender>




有人可以建议我,如果从DATABASE检索一些数据到文本框后文本框为空,如何将水印文本设置为文本框

[edit]已删除呼喊声-OriginalGriff [/edit]




Can any one suggest me , How to Set Watermark text to Textbox if the textbox is null after retriving some data from DATABASE to that textbox

[edit]SHOUTING removed - OriginalGriff[/edit]

推荐答案

尝试删除此行
setTimeout(function(){document.getElementById(''txtUPCDate'').focus()}, 5);
如果您将焦点放在文本框中,则显然不会显示水印.
Try removing this line
setTimeout(function(){document.getElementById(''txtUPCDate'').focus()}, 5);
If you are focusing the textbox, then obviously watermark will not be shown.


这篇关于如何从Javascript将水印文本设置为文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆