Click here to Skip to main content
14,735,210 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to show value inside textbox and not a label

Everybody shows like

Username : <input type="text" name="loginhere" />

I want to show like

<input type="text" name="loginhere" value="Username" />

when input clicked , the value show disappear , and when input not clicked, and button clicked,
check in jquery if value entered, else show alert

1 solution

you can do it using HTML5 and jQuery. Please check following code

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication2.WebForm2" EnableViewState="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
   <script type="text/javascript" src="//"></script>
   <script type="text/javascript">
       function CheckValue() {
           var userName = $("#userName").val();
           if (userName == '')
               alert('user Name is empty');
    <form id="form1" runat="server">
        <input type="text" id="userName" name="userName" placeholder="Username"><br>
     <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick="CheckValue()"  />

maulikshah1990 17-Jan-14 0:14am
thanks ..but already solved with same code ..
Sandeep Singh Shekhawat 17-Jan-14 0:15am
sounds good..Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900