<asp:TextBox ID="TextBox2" runat="server" onblur="ValidateTextNotNull()"></asp:TextBox>
function ValidateTextNotNull() { var Firstname = document.getElementById('TextBox2').value; var textLength = Firstname.length; if (textLength == 0) { alert("show your message"); document.getElementById('TextBox2').focus(); } }
document.getElementById('TextBox2')
document.getElementById('<%=TextBox2.ClientID%>')
Quote:When a Web server control is rendered as an HTML element, the id attribute of the HTML element is set to the value of the ClientID property. The ClientID value is often used to access the HTML element in client script by using the document.getElementById method.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)