Validating all type of controls in a form using javascript Forms Validation

Form Validation in Javascript

 

//**************Blank check validation*********************

        function check_blank(fldid, msgid) {
            var fld = document.getElementById(fldid);
            if (fld.value.length == 0 || fld.value.charAt(0) == "

Validation for blank field in javascript

Here is the code for validate text box for not to be leave blank it pop up a message box when user leave field blank 'The required field has not been filled in' just copy and paste this code and pass the parameter that is id of text box.



function check_blank(tbId) {
    var tbObj = document.getElementById(tbId);
    if (tbObj.value.length == 0 || tbObj.value.charAt(0) == " ") {
        alert("The required field has not been filled in");
        return false;
    }
}
     

How to validate email address in javascript

Recently i have posted how to validate mobile number by javascript, how to validate mobile  number, email address through jquery and now this article will show you how to validate email address using simple javascript or using regular expression in javascript.

How to validate dropdownlist in JavaScript

In this article you will see how to put validation in dropdownlist by javascript, suppose first item value of dropdownlist is 0 and text is "-Select-" just like given below and we have to validate that at least one item is selected excluding default i.e "-Select-".

How to validate mobile number in javascript

Recently i have posted how to validate email address in javascript, how to validate mobile number and email address in jquery and not i will show you how to validate mobile number using simple javascript or using regular expression in javascript.

Validate radiobuttonlist in javascript

Here is the function for validating radiobutton list to select at least on Item through JavaScript radio button list is a ollection of rediobuttons so we have to navigate all sub radio button and check that if selected or not.

Geting controls inside a table in javascript

Often we need to navigate in html container controls like table, div, p etc through JavaScript for doing some type of validation or another task with child of that container control for that we need to

How to open print dialog box to print page or part of the page in JavaScript

some time we need to print only a portion of page or whole page through Javascript, Javascript provide a function named print() to print the current page, so if you want to print whole page then just call window.print() function but if you want to print specific portion of the page then you need to do something extra.

Printing a content of page through javascript


A lot of time as we know that we required make a print functionality to print a our web page as to print a specific portion or a whole page,

Uploading larger file through file upload in asp.net

This article if for how to upload larger file through file upload control in asp.net, we have to change web config setting for uploading larger file through file upload control.

Asp.net Handler For Writing and Downloading Binary

An ASP.NET HTTP handler is the process (frequently referred to as the "endpoint") that runs in response to a request made to an ASP.NET Web application. The most common handler is an ASP.NET page handler that processes .aspx files. When users request an .aspx file, the request is processed by the page through the page handler. You can create your own HTTP handlers that render custom output to the browser.

The HttpHandler is a pre-processing logic implementation blocks and is the part of the ASP.NET request pipeline. Whenever the IIS Server recieves a request, it looks for an ISAPI filter(looking for the perticuler httphandler to handle a perticuler extension) that is capable of handling web requests.


ASP.NET maps HTTP requests to HttpHandlers. Each HttpHandler enables processing of individual HTTP URLs or groups of URL extensions within an application.

Handlers are considered to be more lightweight object than pages. That's why they are used to serve dynamically-generated images, on-the-fly generated PDF-files and similar content to the web browser.

below is an example (.ashx file)..


<%@ WebHandler Language="C#" Class="DownLoad" %>
using System;
using System.Web;
using System.Data;
using System.Data.SqlClient;

public class DownLoad : IHttpHandler {

  CompCls ObjComp = new CompCls();
  public void ProcessRequest(HttpContext context)
  {
     string conString = ObjComp.strCon;
     SqlConnection con = new SqlConnection(conString);
     string Proj = context.Request["id"];
     SqlDataAdapter Ad = new SqlDataAdapter("SELECT   Attachment,AttachmentFileName FROM tblProjectsAttachment WHERE EntryId=@EntryId", con);
    Ad.SelectCommand.Parameters.AddWithValue("@EntryId", Proj);
    DataSet DS = new DataSet();
    Ad.Fill(DS);

    using (con)
     {
        con.Open();
        byte[] file = (byte[])DS.Tables[0].Rows[0][0];
        string Filename = DS.Tables[0].Rows[0][1].ToString();
        try
        {
            context.Response.Clear();
            context.Response.AddHeader
            ("Content-Disposition","inline;attachment; filename=\"" + Filename + "\"");
             context.Response.AddHeader("Content-Length", file.Length.ToString());
             context.Response.ContentType = "application/octet-stream";
             context.Response.BinaryWrite(file);
             context.Response.Flush();
        }
        catch (Exception ex)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Write(ex.Message);
        }

    }
 }

 public bool IsReusable {
    get {
        return false;
    }
 }
}



Want to more about http handler and http module go to below link (httphandler and httpmodule in asp.net)
http://c-sharp-corner.blogspot.in/2012/07/httphandler-and-httpmodule-in-aspnet.html


If We are hosting your application in IIS 7 then you have to do some additional setting in IIS 7 to be register httphandler and httpmodule in IIS 7 take look at this link below.
http://c-sharp-corner.blogspot.in/2012/06/Register httpmodules-and-httphandlers-in-iis-7.html

Comparing two date in JavaScript

This is an article to show how to calculate two date difference using JavaScript.
By subtracting two date java script returns

Back button in JavaScript

Go Back using Java Script:-
Here is an article showing that how to redirect to a back page within client side through java script.

Java Script have a method history.back() by which we can go to the just back page in browser through browser cache if cache not removed otherwise from server side.


<asp:LinkButton ID="btnBack"  runat="server" style="font-size:14px;color: Black ;font-family:Arial;font-weight:bold;" Text="Back" OnClientClick='javascript:history.back(); return false;'  />


Generating random number and string in asp.net c#

Random class defined in the .NET Framework class library provides functionality to generate random numbers.

Making compute column in ado.net with conditions

A question came up in the My Mind as to how to handle Data Column Expressions within a DataTable in Ado.Net. The expression syntax available to create calculated columns is probably much richer than you might think if you don't play around a lot with the Expression Property of the DataColumn.

Sending email in asp.net with email body

This article is for sending email from asp.net with the use of gmail smtp server for that we have to required gmail credential,
asp.net provide SmtpClient class for connecting to the smtp server and MailMessage for getting mail requirement.

Get Server Name and Server Port No in Asp.Net

As we know that there is a need to get server name or port no at run time that request came from where, is port no exist or not to make application dynamic URL, assume when we are working in

Sending emails in asp.net using Gmail Credentials

This article is for sending email from asp.net with the use of gmail smtp server for that we have to required gmail credential,asp.net provide SmtpClient class for connecting to the smtp server and MailMessage for getting mail requirement.

Sorting only current page of gridview in asp.net

How can we sort the displayed rows of current page only? And other pages should not be sort in gridview.
In this article you will see how to sort gridview only current page not all records.

We have to do following task for that:-

Calling server side (cs file) method from client side through Page Method in asp.net C# (CSharp)



// .Aspx Coding //

<script type="text/javascript">

function CallMe(src,dest) {
var ctrl = document.getElementById(src);

Refreshing page in Javascript

In this article we will see that how to refresh or reload a page through Java Script there are a lot of ways to refresh or reload a document depending how we want (from server side

Recent Article