i want to validate my TextBox in the external javascipt file. i tried lots of example using google's help. But i could only access the external javascript file but when trying to perform validation it just returns null. my sample code is below
design page(aspx)
<asp:TextBox ID="txtName" runat="server" ClientIDMode="Static"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" OnClientClick="javascrip:return validate('<%=txtName.ClientID %>')" />
code page(aspx.cs)
page_load()
Button1.Attributes.Add("onclientClick","return Validate(" + txtName.ClientID + ")");
external js(validation.js)
function validate(txtName) {
var element = document.getElementById(txtName);
alert(element);
}
it doesn't recognize clientID and retuns null. please send a sample code to validate TextBox using external java script file.