简体   繁体   English

Jquery水印插件在IE9中将水印作为表单的值提交

[英]Jquery watermark plugin submits watermark as form's value in IE9

I am using this plugin: 我正在使用这个插件:

http://code.google.com/p/jquery-watermark/downloads/detail?name=jquery.watermark-3.1.4.zip http://code.google.com/p/jquery-watermark/downloads/detail?name=jquery.watermark-3.1.4.zip

and problem is it submits the watermark value as textbox's value in IE9. 问题是它在IE9中将水印值作为文本框的值提交。 How can I avoid this issue? 我该如何避免这个问题?

The issue is somewhat related to this post: http://code.google.com/p/jquery-watermark/issues/detail?id=91 该问题与此帖有些相关: http//code.google.com/p/jquery-watermark/issues/detail?id = 91

but the author denies and marks the bug as invalid. 但作者否认并将该错误标记为无效。

You could probably just use some simple JS and CSS and roll your own. 你可能只是使用一些简单的JS和CSS并自己动手。 Using massive all encompassing plug-ins are great when they work. 使用大量的全包插件在工作时非常棒。

http://jsfiddle.net/VF8Dr/ http://jsfiddle.net/VF8Dr/

https://stackoverflow.com/a/14246071/884862 https://stackoverflow.com/a/14246071/884862

CSS CSS

.placeholder { 
  color: gray; 
  position: absolute;
  padding-left: 10px;
}

JS JS

function addPlaceholder(id, text) {
  var elm = document.getElementById(id);
  var ph = document.createElement("SPAN");
  ph.className = "placeholder";
  ph.innerHTML = text;
  elm.parentNode.insertBefore(ph, elm.nextSibling);
  ph.style.left = elm.offsetLeft + 'px';
  ph.style.top = elm.offsetTop + 'px';
  ph.onclick = function() {
    ph.style.display = 'none';
    elm.focus();
  };
  elm.onfocus = function() {
    if(ph.style.display != 'none')
      ph.style.display = 'none';
  };
  elm.onblur = function() {
    if(elm.value == '')
      ph.style.display = '';
  };
}
addPlaceholder("demo", "my text");

Depending on your needs, simple may be best. 根据您的需要,简单可能是最好的。

I know this is very old post but today i faced the same issue. 我知道这是一个很老的帖子,但今天我遇到了同样的问题。 Issue: Watermark value was passing as textbox value. 问题:水印值作为文本框值传递。

Basically i was using Watermark in all of search functionality and the entire search functionality controls are wrapped in update-panel including watermark text box. 基本上我在所有搜索功能中都使用了Watermark,整个搜索功能控件都包含在更新面板中,包括水印文本框。 In my case because of updatepanel, textbox value being passed as watermark value to the serverside. 在我的情况下,由于updatepanel,文本框值作为水印值传递给服务器端。 So i took out watermark textbox out of updatepanel and everything working as expected now. 所以我从updatepanel中取出了水印文本框,现在一切正常。

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

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