Solved

clientclick to validate server side input

Posted on 2014-01-30
1
355 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
[X]
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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Glitching Slide Show 19 27
parsing question on dynamic concatenation 3 34
Calculating percentage 2 30
Can anyone help me find this preloader? 51 43
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…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

733 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