如何从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.