Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

clientclick to validate server side input

Posted on 2014-01-30
1
Medium Priority
?
361 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 2000 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…
Suggested Courses
Course of the Month21 days, 4 hours left to enroll

810 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