Solved

clientclick to validate server side input

Posted on 2014-01-30
1
347 Views
Last Modified: 2014-02-01
Hi Experts,

I have simple <form id="myform" runat="server" action="#">

<input id="mytxt1" runat="server" />
<input id="mytxt2" runat="server" />

<asp:button id="mybutton" onclick="do_stuff" onclientclick="something">
</form>

I need using either jquery or javascript to on clientclick code on client side :

1. get value of mytxt1
2  copy this value to mytxt2

Thanks a lot.
0
Comment
Question by:fpoyavo
1 Comment
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 39823453
You would need to do something like:
    <form runat="server">

        <input id="mytxt1" runat="server" />
        <input id="mytxt2" runat="server" />

        <asp:Button id="mybutton" runat="server" OnClick="do_stuff" OnClientClick="return something();" Text="Click Me" />

    </form>

    <script type="text/javascript">
        function something() {
            document.getElementById('<%= mytxt2.ClientID %>').value = document.getElementById('<%= mytxt1.ClientID %>').value;
            return false;
        }
    </script>

Open in new window

Note: You'll need to take the return false; part out if you want the page to postback. I just added it in to stop the post back so you can see the copy take place.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now