Click here to Skip to main content
15,900,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hiii All,

Please have a look at the following javascript:

C#
if((document.getElementById("TextBox1").value == "") || (document.getElementById("TextBox1").value == "__/__/____"))
   {
            alert ( "Invalid Date" );
            document.getElementById("TextBox1").value="__/__/____";
            document.form1.TextBox1.focus();
            return false;
    }


here, I am giving this script on textchanged event of TextBox1 and its working but its not focusing on TextBox1 when we press tab ..



Regards,
Posted

try this...

document.getElementById("<%=txtName.ClientID%>").focus();
 
Share this answer
 
Comments
Raj.rcr 31-May-11 2:32am    
Hiii Deepthi, its not working yar.. and I have tried the following too.

document.getElementById("TextBox1").focus();
Deepthi Aravind 31-May-11 2:40am    
function TextBoxFocus()
{
$("[id$=_txtName_txt]").focus();

}
please try this script..
See this[^] discussion.
 
Share this answer
 
C#
var id = document.getElementById('TextBox1');
if((id.value == "") || (id.value == "__/__/____"))
   {
            alert ( "Invalid Date" );
            id.value="__/__/____";
            id.focus();
            return false;
   }
 
Share this answer
 

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