Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

clientclick to validate server side input

Posted on 2014-01-30
1
353 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

809 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