Search This Blog


Nov 20, 2010

How to check Empty field using JavaScript

Sponsored Links:

This is very generic function which will check the value of control whether they are empty or not.

Uses: We can use this function to define the mandatory field of your application

JavaScript function

function CheckIfEmpty(ctl)
Here ctl is the name of
the control, whose value you want to check

if (
alert("Field can not be blank");
return false;
return true;

and how to call in aspx page

<form id="form1" runat="server">
<asp:TextBox ID="myTextBox" runat="server" 

Above method will fire if the value of TextBox(myTextBox) is blank, in other word’s we are making this field mandatory.

Follow by Email