質問

I am using jQuery watermark plugin to apply watermark on my ASP.NET text boxes. The textbox also has ASP.NET validations attached to it. When I click on any button on the page, the watermark disappears. Interesting part is, watermark appears when I take focus on the textbox and then take the focus away from it. So, button click made the watermark invisible.

Can anyone find why this occurs?

役に立ちましたか?

解決

According to the Usage Notes:

Form submission - The plugin automatically cleans up all watermarks prior to form submission, so you should never need to manually remove watermarks before submit.

In other words, this is by design. The feature is so you don't accidentally post the watermark and mistake it as entered data.

You can see by the source code starting at line 425, it provides the following explanation:

// In order to reliably clear all watermarks before form submission,
// we need to replace the form's submit function with our own
// function. Otherwise watermarks won't be cleared when the form
// is submitted programmatically.

This is why any postback, full or partial, would result in the watermark being cleared. (Any postback submits the form.)

If you want the watermark to display again, for a partial postback, you will need to reload it. ($.watermark.showAll();)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top