check with javascript if textbox is empty while using ajaxcontroltoolkit TextBoxWatermark

I have an asp.net TextBox and I'm using the TextBoxWatermark of AjaxControlToolkit to have it display some hing text while the box is empty.

Problem is, onclient click of a certain button, I want to determine if the textbox is empty. The javascript code of

document.getElementById(fieldName).value == ""

Is not working, since the WaterMark extender with it's hint text making the code to think the field is not empty.

Any solution to this?

Answers


You can use the wrapper to access whether the watermark is being displayed or not with get_IsWaterMarked.

Sys.Extended.UI.TextBoxWrapper.get_Wrapper(document.getElementById(fieldName)).get_IsWatermarked()

I tried this with version 4.1.7.1213 of AjaxControlToolKit.

Got the code from looking at the source code of the TextBoxWatermark control. Refer to this: http://ajaxcontroltoolkit.codeplex.com/SourceControl/latest#Client/MicrosoftAjax.Extended/TextboxWatermark/TextboxWatermark.pre.js


Need Your Help

Disable Orientation in iphone app. iOS 7 - Xcode 5

ios iphone orientation landscape

I created iphone and ipad app using Xcode 5, iOS 7.

How to keep the AngularJS template updated while getting socket updates?

angularjs sockets

I get updates from the Backend via socket connections. I want to have an automatically updating Frontend with AngularJS while using a data object for the data I got from the Backend.