Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1660
  • 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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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