views:

26

answers:

2

Hi, How we can avoid the saving of watermark text of a textbox while saving? In my application, I have one textbox which has a watermark text like enter value(by using ajax textbox watermark extender). when i save the form, the text box returns the value of some white space corresponding the letters of the water mark text. And i used to trim(). but it is saving as old manner. Please help me for avoiding this one. thanks in advance..

A: 

You can follow the approach used by the jquery watermark plugin.

The plugin listens on form submit, intercepts the submit, and sets the value of any inputs that contain only the watermark text to the empty string before allowing the submit to continue. You could do the same thing with ms ajax.

If you're open to it, and if you want to be a generally happier person, you could just add in jquery and the watermark plugin. It will take care of this issue for you. You can find the plugin here.

Rob
A: 

Alternatively you can use HTML5 placeholders, or jQuery hint that handles it for you:

http://remysharp.com/2007/01/25/jquery-tutorial-text-box-hints/

http://diveintohtml5.org/detect.html#input-placeholder

Steve-o