Click here to Skip to main content
15,913,487 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
if(!checkDate(document.getElementById("txtUPCDate").value) )
         {
        alert ( "Invalid Date" );
        document.getElementById("txtUPCDate").value="";
         setTimeout(function(){document.getElementById('txtUPCDate').focus()}, 5);
        return false;
        }


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>



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]
Posted
Updated 27-Jun-11 22:31pm
v2
Comments
OriginalGriff 28-Jun-11 4:31am    
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalisation if you want to be taken seriously.

1 solution

Try removing this line
setTimeout(function(){document.getElementById('txtUPCDate').focus()}, 5);
If you are focusing the textbox, then obviously watermark will not be shown.
 
Share this answer
 
Comments
SARAVANAKUMAR.M 28-Jun-11 5:06am    
ok Prerak , instead of that line, if i use
document.getElementById('txtUPCDate').focus();
means then focus is not focusing on txtUPCDate textbox in mozilla firefox .
Prerak Patel 28-Jun-11 5:08am    
I am just saying that if you want to focus the textbox, watermark will not be shown. Watermark is visible only if textbox is not focused.
SARAVANAKUMAR.M 28-Jun-11 5:21am    
ya , even i want to make watermark visible to the textbox after the textchange of that textbox
Prerak Patel 28-Jun-11 7:11am    
Are you sure you want watermark?! I mean, showing watermark even after text change! What does it serve?
SARAVANAKUMAR.M 28-Jun-11 7:55am    
ya , but if that textbox is null then textbox text should be watermark text , that is what i want to say .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900