简体   繁体   English

使用ajaxcontroltoolkit TextBoxWatermark时使用javascript检查文本框是否为空

[英]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. 我有一个asp.net TextBox,正在使用AjaxControlToolkit的TextBoxWatermark使其在框为空时显示一些附加文本。

Problem is, onclient click of a certain button, I want to determine if the textbox is empty. 问题是,onclient单击某个按钮时,我想确定文本框是否为空。 The javascript code of 的javascript代码

document.getElementById(fieldName).value == "" 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. 不起作用,因为带有提示文本的WaterMark扩展程序使代码认为该字段不为空。

Any solution to this? 有什么解决办法吗?

You can use the wrapper to access whether the watermark is being displayed or not with get_IsWaterMarked . 您可以使用包装器通过get_IsWaterMarked来访问是否显示水印。

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

I tried this with version 4.1.7.1213 of AjaxControlToolKit. 我尝试使用AjaxControlToolKit的4.1.7.1213版本进行此操作。

Got the code from looking at the source code of the TextBoxWatermark control. 通过查看TextBoxWatermark控件的源代码获得了代码。 Refer to this: http://ajaxcontroltoolkit.codeplex.com/SourceControl/latest#Client/MicrosoftAjax.Extended/TextboxWatermark/TextboxWatermark.pre.js 引用此: http : //ajaxcontroltoolkit.codeplex.com/SourceControl/latest#Client/MicrosoftAjax.Extended/TextboxWatermark/TextboxWatermark.pre.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM