• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1765
  • Last Modified:

using onmouseout for asp.net textbox

HI EE,
I have 10 text boxes in my form.My requirement is Users have to fill txtbox1 inorder to fill txtbox2
This i have to implement using Javascript(not using AJAX).
0
agcps
Asked:
agcps
2 Solutions
 
Kumaraswamy RCommented:
Hi

Bellow url give some information

http://forums.asp.net/t/1290832.aspx
0
 
agcpsAuthor Commented:
Hi
I'm new to programming can you plz explain me step by step using C#.net as code behind.
0
 
rajeeshmcaCommented:
Hi agcps,

Try this..

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript" language="javascript">
    function ChecktextBox(obj)
    {
        if(obj.value == "")
        {
            document.getElementById("TextBox2").disabled = true;
        }
        else
        {
            document.getElementById("TextBox2").disabled = false;
        }
    }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:TextBox ID="Textbox1" runat="server" onblur="ChecktextBox(this)" ></asp:TextBox>
    <asp:TextBox ID="Textbox2" runat="server" Enabled="false"></asp:TextBox>
    </div>
    </form>
</body>
</html>

there is no need of any code in the codebehind
0
 
shrinivasmwCommented:
Here is 2nd running code

It will solve your problem for sure... Save following code in any HTML file and test... It works.

Understand how I am calling JS method for it and you can do it for all 10 controls if required.


<html >
<head runat="server">
    <title>Untitled Page</title>
    <script language="javascript">
    
    function Test(textBoxId)
    {
        if(document.getElementById(textBoxId.toString()).value == "")
        {
            alert("Please enter value in " +  textBoxId.toString());
        }
    }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <input type="text" id="txtIn" />
    <input type="text" id="Text1" onmousedown="javascript:Test('txtIn')" onfocus="javascript:Test('txtIn');"  />
    
       </div>
    </form>
</body>
</html>

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now