How to change WaterMark font size using jQuery in ASP.Net

Last Reply on Jun 08, 2017 08:53 AM By Indresh

Posted on Jun 07, 2017 04:40 AM

hi I use watermark for textbox in page and I define fontsize for watermark

below are code:

       <script type="text/javascript">
        window.onload = function SetColorOnPageLoad() {
            var defalutAzText = "از";
            var defalutTaText = "تا";
            var defalutsearch = "جستجو بر اساس کد ملک";
            functionSetColor(document.getElementById("Txtsearch"), defalutsearch);
            functionSetColor(document.getElementById("Txtejare1"), defalutAzText);
            functionSetColor(document.getElementById("Txtejare2"), defalutTaText);
            functionSetColor(document.getElementById("txtvadi1"), defalutAzText);
            functionSetColor(document.getElementById("txtvadi2"), defalutTaText);
        }

         function functionSetColor(Textbox, WaterMark) {
        if (Textbox.value.length > 0 && Textbox.value == WaterMark) {
            Textbox.style.color = "#443f13";
            txt.style.fontSize = "14.5px";
 
        } else {
            Textbox.style.color = "white";
            txt.style.fontSize = "14.5px";
        }
    }
 
    function WaterMark(txt, evt, msg) {
        if (txt.value.length == 0 && evt.type == "blur") {
            debugger;
            txt.style.color = "#443f13";
            txt.value = msg;
            txt.style.fontSize = "14.5px";
            txt.style.fontfamily = "behtop_Yekan";

        }
 
        if (txt.value == msg && evt.type == "focus") {
            txt.style.color = "white";
            txt.value = "";
            txt.style.fontSize = "14.5px";
            txt.style.fontfamily = "behtop_Yekan";
        }
    }
</script>

problem is that here at first when run page it shows watermark with size that I define for textbox (in css) and when I click on textbox and after that  click out of text box it will display watermark's fontsize  that I define an above code

please refer below video:

https://vimeo.com//220612125

 

best regards

neda

 

Results 1 - 5 of 10 12
Posted on Jun 08, 2017 08:53 AM

Posted on Jun 08, 2017 07:28 AM

hi indresh

I refer your code it will show water mark in 14.5px but now problem is that when I type into textbox it will type in 14.5px but I want when I type in textbox  it will type in 18px (as I define in css)

best regards

neda


Posted on Jun 08, 2017 06:25 AM

Hi nedash,

Please refer the below link. As per your requirement I have given sample working code.

http://www.aspforums.net/Threads/479914/how-to-change-watermark-fontsize/Replies/3#Replies


Posted on Jun 08, 2017 06:01 AM

hi indresh

I see your screenshot my problem is excactly show in your screenshot when run page watermark will show in  25px(fontsize in css) and when click on textbox it will display correclty in 14.5px(as define)

I want when I run page watermark display in 14.5px(not fontsize in css)

best regards

neda


Posted on Jun 08, 2017 02:42 AM