.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

ASP.NET Page Validation

Posted By: Rama Krishna     Posted Date: March 13, 2013    Points:5   Category :ASP.Net

i have 10 text boxes in my form.
whenever i clicked on submit button...i want to check whether all the textboxes filled or not?

Author: satyapriyanayak          Accepted Answer   
Posted Date: March 13, 2013     Points: 40   

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="WebApplication17.WebForm4" %>

<!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 runat="server">
<title>Untitled Page</title>
<script type="text/javascript" language="javascript">
function CheckTextBoxes()
var TextBox1 = document.getElementById('<%=TextBox1.ClientID %>');
var TextBox2 = document.getElementById('<%=TextBox2.ClientID %>');
var TextBox3 = document.getElementById('<%=TextBox3.ClientID %>');
var TextBox4 = document.getElementById('<%=TextBox4.ClientID %>');
var TextBox5 = document.getElementById('<%=TextBox5.ClientID %>');

if (TextBox1.value == "" || TextBox2.value == "" ||TextBox3.value == "" || TextBox4.value == "" || TextBox5.value == "")
alert('Fields should not be blank');


<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox><br />
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox><br />
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox><br />

<asp:Button id="Submit" Text="Submit" runat="server" OnClientClick="CheckTextBoxes();"/><br />


If this post helps you mark it as answer
Author: Rama Krishna             
Posted Date: March 14, 2013     Points: 20   

Thanks A lot...Dear Frnd

Author: Deco             
Posted Date: March 20, 2013     Points: 20   

You can also loop through all the texbox controls and can check if it is empty. if a texbox is empty skip out of the loop and tell the user that the textbox is empty. This will shorten the coding and will fetch the result in a faster way.

Author: John             
Posted Date: November 07, 2013     Points: 20   

In an ASP.NET Web page, you can set to two culture values, the Culture and UICulture properties. The Culture value determines the results of culture-dependent functions, such as the date, number, and currency formatting, and so on. The UICulture value determines which resources are loaded for the page.

For more :-http://www.karmickinstitute.com/dot-net-course.html

Karmick Institute

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend