<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="TestToOnFocus.test" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <script src="test.js"></script> <title>Test</title> </head> <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="txtName" runat="server" ClientIDMode="Static"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return test();"/> </div> </form> </body> </html>
function test() { var name = document.getElementById("<%= txtName.ClientID %>").value; if(name=="") { alert("Please"); } else { alert(name); } }
function test() { var name = document.getElementById("<%= txtName.ClientID %>").value; if(name=="") { alert("Please"); return false; } else { alert(name); return true; } }
<script language ="javascript" type ="text/javascript" > function validate() { if(document .getElementById("<%=txtName.ClientID%>").value=="Select") { alert ("Please "); document.getElementById("<%=txtName.ClientID%>").focus(); return false ; } } </script>
document.getElementById("<%= txtName.ClientID %>").val();
document.getElementById("<%= txtName.ClientID %>").value;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)