textbox water mark

on Apr 30, 2015 09:03 PM


I use below code to putting water mark for textbox

    <script type="text/javascript">
        var defaultText = "Enter Your Text here";
        function WaterMark(txt, evt) {
            if (txt.value.length == 0 && evt.type == "blur") {
                txt.style.color = "#b9b9b9";
                txt.value = defaultText;
            if (txt.value == defaultText && evt.type == "focus") {
                txt.style.color = "black";
                txt.value = "";

but when I click on button to insert data into database if I don't type any text in textbox it insert in database defult text :

"Enter Your Text here";

but I want if I don't type anything in textbox it doesn't insert any thing into database

Best Regards



Download FREE API for Word, Excel and PDF in ASP.Net: Download
on Apr 30, 2015 09:05 PM

Add a checking before Insert

if(TextBox1.Text != ""Enter Your Text here"")