Sie sind auf Seite 1von 5

In Focus

C# Corner
Visual Studio 2017 Live

Using JavaScript
Siddu Soraganvi Jun 05 2017 Blog

2 0 10.3k

Download Free O�ce API

Today we are going to learn how to validate the Text Box using the java script
in asp.net.

First create the Text box and one button in your aspx �le as I have written the
code to create the text box and button below.

ASP.Net Code

01. <body>  
02.     <form id="form1" runat="server">  
03.     <div>  
04.       
05.         <table class="style1">  
06.             <tr>  
07.                 <td>  
08.                     <asp:Label ID="Label1" runat="server" Text="User Name">
</asp:Label>  
09.                          
10.                     <asp:TextBox ID="txtUName" runat="server"></asp:TextBox>  
11.                 </td>  
12.             </tr>  
13.             <tr>  
14.                 <td>  
15.                     <asp:Label ID="Label2" runat="server" Text="Password">
</asp:Label>  
16.                            
17.                     <asp:TextBox ID="txtPwd" runat="server"></asp:TextBox>  
18.                 </td>  
19.             </tr>  
20.             <tr>  
21.                 <td>  
22.                                 
23.                     <asp:Button ID="btnLogin" runat="server" Text="Login" Width="120px"
24.                         OnClientClick="return userValid();" />  
25.                      </td>  
26.             </tr>  
27.         </table>  
28.       
29.     </div>  
30.     </form>  
31. </body>  
In Focus
C# Corner
Visual Studio 2017 Live

01. <script type="text/javascript">    
02.     
03.         function userValid() {    
04.            var UName= document.getElementById("txtUName").value;    
05.            var Pwd= document.getElementById("txtPwd").value;    
06.     
07.            if (UName == '')    
08.            {    
09.             alert("Please enter User Name");    
10.             return false;    
11.            }    
12.     
13.            if (Pwd == '')    
14.            {    
15.            alert("Please enter Password");    
16.            return false;    
17.            }    
18.         }    
19.      </script>     

If you like the above blog please do like and comment... :)  

Text Box Validation ASP.NET JavaScript

Siddu Soraganvi

1656 22.7k

2 0
In Focus
C# Corner
Visual Studio 2017 Live

Hire a blockchain developer


Want to get your applications built on Blockchain technology?
Come, meet the blockchain experts and hire a team or
individuals as per your need.

LATEST BLOGS
.NET Core - Basic Information

How Volunteering Strengthens Your Commitment

Union V/S Join In SQL

SharePoint Designer Work�ows And OOTB Work�ows Stopped Working


Suddenly

Reset Your Dynamics 365 V9 Trial To V8.2

Microsoft Flow - Recurring Work�ow To Copy Files From Local Shared Path To
SharePoint Document Library

Change Document Library URL Without SharePoint Designer

How To Create Custom Shape In Adobe Photoshop 7.0

Technology That Will Prevail In iOS App Development In Coming Years

First Letter In Uppercase in C#

View All
In Focus
C# Corner
Visual Studio 2017 Live

Philadelphia
New York
London
Delhi

Join C# Corner
and millions of developer friends worldwide.

Enter your email address Sign Up

Learn ASP.NET MVC Learn ASP.NET Core Learn Python


Learn JavaScript Learn Xamarin Learn Oracle More...
In Focus
C# Corner
Visual Studio 2017 Live

About Us Contact Us Privacy Policy Terms Media Kit Sitemap


Report a Bug FAQ
©2018 C# Corner. All contents are copyright of their authors.

Das könnte Ihnen auch gefallen