Getting Textbox Watermark Text in client side javascript

Can somebody tell me how I can go about grabbing the Text value of a TextBoxWatermark control from client side javascript?  I need to make a comparison/validation if a text box has been filled out (non-blank) and of course the watermark fills in the text value of the text box when grabbing the property (of the text box) per javascript?

So, I need to somehow grab the text from the watermark in javascript and then compare to the text box contents to see if the text in the textbox is the water mark text or not.

 Any information would be greatly appreciated.

 Thanks!

0
JacquoJohnson
3/28/2007 7:11:08 PM
asp.net.ajax-ui 9760 articles. 0 followers. Follow

2 Replies
1216 Views

Similar Articles

[PageSpeed] 10

 This example is a modified version of the the Toolkit's TextBoxWatermark.aspx.  The key is assigning a BehaviorID to the TextBoxWatermarkExtender and then you can locate it using $find.

 
<asp:Content ContentPlaceHolderID="SampleContent" Runat="Server">
    <script>
    
        function compareText()
        {
            var tb = $get("<%=TextBox1.ClientID %>");
            var behavior = $find("Extender1");
            if(tb.value == behavior._watermarkText)
            {
                alert("Value has not changed!");
            }
            else
            {
                alert("Value has changed!");
            }
        }
    </script>
    <asp:ScriptManager EnablePartialRendering="true" runat="Server" />
    <div class="demoarea">
        <div class="demoheading">TextBoxWatermark Demonstration</div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                First name:
                <button onclick="compareText()" value="aaa">aaa</button>
                <asp:TextBox ID="TextBox1" CssClass="unwatermarked" Width="150" runat="server" /><br />
                <ajaxToolkit:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server"
                    TargetControlID="TextBox1"
                    WatermarkText="Type First Name Here"
                    WatermarkCssClass="watermarked" BehaviorID="Extender1" />
            
                Last name:
                <asp:TextBox ID="TextBox2" CssClass="unwatermarked" Width="150" runat="server" /><br /><br />
                <ajaxToolkit:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender2" runat="server"
                    TargetControlID="TextBox2"
                    WatermarkText="Type Last Name Here"
                    WatermarkCssClass="watermarked" />
            
                <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit" />
                <br /><br />
                <asp:Label ID="Label1" runat="server" />
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <div class="demobottom"></div>




Please remember to "mark as answered" posts that have helped you.

-----
http://lsudotnet.blogspot.com
0
LSU
3/28/2007 7:33:11 PM
Beautiful!  Thanks for replying!  I will give it a try!
0
JacquoJohnson
3/28/2007 8:41:07 PM
Reply:

Similar Artilces:

Get the Dropdownlist text and value using Javascript from client side
Hi, I am encountering a problem about how to get the Dropdownlist text and value using Javascript from client side. I am using C# in Visual Studio 2005 and Javasript . The example codes are like: ( In this example code, I would like to access the text and value of the DropDownListReports in the run() function of Javascript. How can I do that? Any ideas? Thanks a lot. ) protected void Page_Load(object sender, EventArgs e) {              if (!Page.IsPostBack)            &nb...

length or trim ? how can i get textbox.text as text that publichouse to textbox.text as text that public ?
hello friends length or trim ? how can i get textbox.text as text that publichouse to textbox.text as text that public ? second example is ..... textbox1.text is greenhouse.. i want to get green from textbox.text cheer Mark as me if my question or my answer can be helpful for you :) Hi,you can always perform a Trim to a retrieved string to delete the leading and trailing space characters. For your second example where you want to gt a part of the retrieved string you can use the SubString method of the String class.Grz, Kris. Read my blog. Handy Firefox plugins for web developers.Workar...

How to get the text of textbox(the textbox inside a datagrid) by using a javascript function
Hi there, I have a datagrid in my web application. Inside the datagrid, I have web controls such as dropdownlist and textbox. Everytime I change selection of dropdownlist I want use a javascript function to get the value of dropdownlist and text in textbox. How can I do that? Thanks   Colin Hello, Getting the value of the DDL (DropDownList) is not really a problem . The textbox on the other hand might be. In your Page_Load event Handler you can add theses lines to add an event handler to the DDL in the Client side: myDDL.Attributes.Add("OnChange", &quo...

Textbox Watermark (Ajax Tookit) does allow for standard text watermark on Password fields.
I'm using the Ajax Tookit TextWatermark control:http://www.asp.net/AJAX/AjaxControlToolkit/Samples/TextBoxWatermark/TextBoxWatermark.aspx I'm using it for my login and I have the text "User Name" in the username field. Although for the password field, when I set watermarktext, it shows up as "*" rather than the desired text "Password". Is there a way to have the watermark show as regular text and still have the password masked with "*" when the user actually types in the password to login? Thanks,Levi May you can use nomal textbox instead o...

how do i get selectedValue of drop down list server side if i am populating it using client side javascript?
 Hi All.I am populating a drop down list client side using: The drop down list is populated based on a selection of another drop down list. ddlList.options[i] = new Option(1,2); as an exampleThe populating is done as i need it to. However, a button click event i am trying to get the selectedValue of the ddlList. However, it doesn't give me it. It only gives me the selectedValue of the drop down list on first rendering. Any ideas on how i can get it?   Could You paste some code? That would be helpful. Thanks S@ss (Shashi Shekhar Singh)My BlogPlease mark a post as ANSWER ...

TextBox with client-side javascript
I'm using an ASP.net "<asp:TextBox" control, which renders as the standard html "<input type=text" control. The HTML control has an onClick event for entering javascript.  I want to use this client-side event.  However the ASP.net control "<asp:TextBox" doesn't seem to have an onClick event.  The "onXXX" events it does have seem to be server side anyway. How can I specify custom javascript for the onclick event of an "<asp:TextBox" control? Why didn`t you try it? "" In ASP.NET 2.0 the event is called "OnClientScript". You won`t know until you`ll try it!Hap...

pls help: how to get client-side HTML "text field" value from a server side button
i copy some javascript from somewhere so user can choose pick up a date from a calendar and display the date onto a HTML text field. I have no knowledge in writing client side script(i.e. write code in html) can i write some code in a server-side button to get the value in the HTML text field??? i tried: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click textbox1.text = document.getElementById("htmltext").value End Sub but "document" is highlighted, and say isn't declar yet. and...

How to validate text in a textbox on CLIENT SIDE?
 HiI have validate a TextBox on WebForm, such that the user is able to enter only numbers in the TextBox, on the Client Side, i.e. without posting back to the server.I have user CustomValidator and a JavaScript function to validate the number in the TextBox to be divisible by, say 5, reading an example from a book.What function do I use to check whether the text in the TextBox is numeric or not? Or there anything like SendKeys or KeyPress.Handle?Thanks in advance.  Kumar Kush You can do this... <asp:TextBox ID="txtNumbers" runat="server" onkeypress="r...

Get textbox value in client side
My problem is that in my ascx file i have a textbox & a input buttom with a javascript function that will validate the textbox: .... <script lang="javascript"> function Test() { if (document.all.txt1.value == "") { alert(); return; } } </script> .... <asp:textbox id="txt1" runat="Server"></textbox> <input type=button id="cmd1" onclick="javascript:Test();" value="Add"> .... But the function don't work, because the textbox control isn't...

.Net varible into client side JavaScript
I'm need to get a variable from my web app and place its value in a JavaScript. I tried doing this with a Label but I get the HTML included. I don't think I can use the <%# %> from classic ASP? Anyone have any ideas on how they would approach this problem? tbone_stl wrote:Anyone have any ideas on how they would approach this problem? Hi, and welcome to the ASP.NET forums. It's possible to pass a variable to a javascript function. I created a small coding snippet: <%@ Page Language="C#" %>   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http...

populate javascript client side with ajax.
I have the following:function year_onchange(sender, e) {var y = ddlYear.options[ddlYear.selectedIndex].text; var m = ddlMonth.value;   // Add an Option object to Drop Down/List Boxvar totalDaysInMonth = daysInMonth(m, y);var element = document.getElementById("ddlDay"); alert (totalDaysInMonth);for (var i = 0; i < totalDaysInMonth; i++) {element.options[element.length] = new Option(i, i); } } It does not populate the dropdownlist in the below code.<asp:Label ID="lblDOB" runat="server">Date of Birth: </asp:Label> &nbsp; &l...

How to get a variable to Runatserver from Client Side Javascript
Here is a snippet of the Javascript Code if (VarNotCompleted == "YES") {document.getElementById("RatingLabel").innerHTML="Not Completed"} else {document.getElementById("RatingLabel").innerHTML=VarRating} It works fine but when I want to take the contents of the rating label back to the database it doesn't work. I am assuming the probem is that the Javascript is client side and nothing is registering at the server How to I get the Javascript generated contents of Rating Label back to the server This is the label <...

How to get TextBox text value from a javascript variable ?
How can I get text value from a javascript variable ?Example:Javascript function: var text="Hello";function GetText() { return text;} Here I need to get a text value from a javascript function.Code like this:  <asp:TextBox ID="txtMyText" runat="server" text="GetText()" />How to do it?  Try this: <form id="Form1" method="post" runat="server"> <asp:TextBox id="txtMyText" runat="server"></asp:TextBox></form <script type="text/javascript&qu...

Insert text into server side textbox with JavaScript
I have a piece of JavaScript that when a client side button is pushed it will put text into a client side text box.How can I alter this to carry out the same action but put the text into a server side asp.net textbox instead of the clients side text box?  Add runat="server" to the clientside textbox tag, and give it an ID (if it hasn't already got one) Regards Mike [MVP - ASP/ASP.NET]My site Will try that, thanks....

Web resources about - Getting Textbox Watermark Text in client side javascript - asp.net.ajax-ui

JavaScript Kit- Your comprehensive JavaScript, DHTML, CSS, and Ajax stop
Your comprehensive JavaScript, DHTML, CSS, and Ajax stop

Let's Code: Test-Driven Javascript by James Shore — Kickstarter
James Shore is raising funds for Let's Code: Test-Driven Javascript on Kickstarter! A screencast series focusing on rigorous, professional Javascript ...

Eloquent JavaScript: A Modern Introduction to Programming
... and pragmatics. I loved the tutorial-style game-like program development. This book rekindled my earliest joys of programming. Plus, JavaScript! ...

Lightbox (JavaScript) - Wikipedia, the free encyclopedia
On a Lightbox-enabled page, a user can click an image to have it magnified in a Lightbox window, which resizes itself according to the size of ...

Open Directory - Computers: Programming: Languages: JavaScript: Tools: Obfuscators
about dmoz - help Top : Computers : Programming : Languages : JavaScript : Tools : Obfuscators Tools for obfuscation/compression JavaScript code. ...

Facebook File-Transfer App Pipe Relaunches, Now Works Via JavaScript, WebRTC
... allowed Facebook users to send and receive files up to 1 gigabit in size. A new version of Pipe debuted Monday, and the app now works via JavaScript ...

Under the Hood: The JavaScript SDK - The use of polyfills - Facebook
Facebook Engineering hat eine Notiz mit dem Titel Under the Hood: The JavaScript SDK - The use of polyfills geschrieben. Du kannst den vollständigen ...

JavaScript SDK - Facebook-Entwickler
Overview The JavaScript SDK provides a rich set of client-side functionality for accessing Facebook...

Senior Front-End Developer (Javascript and AJAX)
Company: Sometrics Category: Software Development Location: Los Angeles, CA How to Apply: jobs@sometrics.com Description: We are looking for ...

Badass JavaScript (@badass_js) on Twitter
WebGLWorker is an open source library that allows using WebGL from Web Workers. Great work as always from @kripken . blog.mozilla.org/research/2014/… ...

Resources last updated: 12/3/2015 1:52:59 PM