I saw many ppl have solution for add a watermaker to text fields.
 http://www.mkyong.com/jquery/jquery-watermark-effect-on-text-input/
 http://www.davidjrush.com/blog/2011/10/jquery-creating-a-textbox-text-watermark/

But their solution is not what I want, because it set the value to the text field..and it will be submit with real data when you click submit button.


So I make some improvement.
My solution is use a div to display watermaker message:
<style>
  .watermark { color#999position:absolute }

</style>
<script type="text/javascript">
    
function
SetWatermaker(targetId,text) { var target = $('#' + targetId); target.after('<div class="watermark" style="position: absolute;" id="wm' + targetId + '">' + text + '</div>'); var p = $('#' + targetId).offset(); p.left = p.left + 8; p.top = p.top + 3; var targetWm = $('#wm' + targetId); targetWm.offset(p); target.focusout(function() {
if(target.val()=="")   targetWm.show();
 else
   targetWm.hide();         }); target.focus(function() { targetWm.hide(); }); }

    $(document).ready(function () {        SetWatermaker("txtMACAddress""AA:BB:CC:DD:EE:FF");      });
</script>




 
Comments are closed.