design:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="login.aspx.cs" Inherits="INSERT_UPDATE_DELETE.login" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>Untitled Page</title> <script src="../validation.js" type="text/javascript"></script> </head> <body> <form id="form1" runat="server"> <div> <table align="center"> <tr> <td> USERNAME </td> <td> <asp:TextBox ID="TextBox1" runat="server" Height="24px" Width="133px"></asp:TextBox> </td> </tr> <tr> <td> PASSWORD </td> <td> <asp:TextBox ID="TextBox2" runat="server" Height="22px" Width="133px"></asp:TextBox> </td> </tr> <tr> <td> </td> <td> <asp:Button ID="btnSave" runat="server" Text="Insert" OnClick="btnSave_Click" OnClientClick="return isvaliduser();" /> </td> </tr> </table> </div> </form> </body> </html>
validation.js
function isvaliduser() { if (document.getElementById("<%=TextBox1.ClientID%>").value == "") { alert("Name cannot be blank"); document.getElementById("<%=TextBox1.ClientID%>").focus(); return (false); } }
Hi smuthu,
Check the folder structure.
If your page is in a subfolder, then use
<script src="../validation.js" type="text/javascript"/>
else
<script src="validation.js" type="text/javascript"/>
or adjust accordingly.
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.