Wednesday, October 12, 2011

How to integrate CSS in XML file.

Here i m showing some xml file test like...........

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/css" href="catalog.css"?>
<CATALOG>
  <CD>
    <TITLE>Empire Burlesque</TITLE>
    <ARTIST>Bob Dylan</ARTIST>
    <COUNTRY>USA</COUNTRY>
  </CD>

</CATALOG>
In the above line i have mention there how to include css file reference with href tag
Now question is that how to declare the css property .
css file format here.

CATALOG
{
background-color: #ffffff;
width: 100%;
}
CD
{
display: block;
margin-bottom: 30pt;
margin-left: 0;
}
TITLE
{
color: #FF0000;
font-size: 20pt;
}
ARTIST
{
color: #0000FF;
font-size: 20pt;
}
COUNTRY
{
display: block;
color: #000000;
margin-left: 20pt;
}
Then its automatically worked with xml.
Thanks

Friday, September 23, 2011

TEXT BOX IN ASP.NET THROUGH CODING

Here is a form in which we want to display the test box on form loading.
<form id="form1" runat="server">
    <div>
       
    </div>
    </form>


In the page load method

protected void Page_Load(object sender, EventArgs e)
        {
            form1.Controls.Add(newTextBox());    //  
newTextBox() is the method who return the test box
        }

private TextBox newTextBox()
        {
            TextBox tx = new TextBox();

           
tx.ID = "TextBox1";
           
tx.Text = "some text";
           
tx.TextMode = TextBoxMode.MultiLine;
           
tx.Attributes.Add("runat", "server");
           
tx.Rows = 3;
           
tx.AutoPostBack = true;
                    
            tx.TextChanged += new EventHandler(tb_TextChanged);    // event handelar
           
            return tx;
        }


Try and enjoy

Wednesday, August 24, 2011

Asp.net Image validation.

In asp.net ,to validate the image extension you can use the regular expression like that.
<asp:RegularExpressionValidator ID="revImage" ControlToValidate="uplImage" ValidationExpression="^.*\.((j|J)(p|P)(e|E)?(g|G)|(g|G)(i|I)(f|F)|(p|P)(n|N)(g|G))$" Text=" ! Invalid image type" runat="server" /> 
Here the group of  image extension  array will check the extension and display the error message.

Tuesday, March 1, 2011

Captcha in asp.net

Creat the captha.cs class like.
public partial class captcha : System.Web.UI.Page{

{
protected void Page_Load(object sender, EventArgs e)try{
System.Drawing.
System.Drawing.
objGraphics.Clear(System.Drawing.
objGraphics.TextRenderingHint = System.Drawing.Text.
System.Drawing.





{

strRandom += strArray[i].ToString();
}
Session.Add(
objGraphics.DrawString(strRandom, objFont, System.Drawing.
Response.ContentType =
objBmp.Save(Response.OutputStream, System.Drawing.Imaging.
objFont.Dispose();
objGraphics.Dispose();
objBmp.Dispose();
}
Bitmap objBmp = new System.Drawing.Bitmap(156, 25);Graphics objGraphics = System.Drawing.Graphics.FromImage(objBmp);Color.Gray);TextRenderingHint.AntiAlias;Font objFont = new System.Drawing.Font("Blue", 12, System.Drawing.FontStyle.Bold);string strRandom = "";string[] strArray = new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };Random autoRand = new Random();int x;for (x = 0; x < 5; x++)int i = Convert.ToInt32(autoRand.Next(0, 36));"strRandom", strRandom);Brushes.Black, 3, 3);"image/GIF";ImageFormat.Gif);catch{
}
}

{
ViewStateUserKey = Session.SessionID;
}
}

And use it to desier page like.

<

For check the capthca test using

aa = txtCaptcha.Text;

{
msg.InnerHtml =
txtCaptcha.Text =
txtCaptcha.Focus();
}

strRandom session automatically store the value of Captcha test.
if (Session["strRandom"].ToString() != aa)"Enter valid captcha string";"";
asp:Image ID="img_cap" ImageUrl="~/captcha.aspx" runat="server" />
private void Page_Init(object sender, EventArgs e)

Java Script calendar in Asp.net.

Step 1
              Write down the java script code in Head tag of the asp Page.
  script language="javascript" type="text/javascript"> ShhowCalendar(SourceControl,DestinationControl)"dd/mm/yyyy");return false;</script><script language="javascript" type="text/javascript">// Check browser versionvar
var
isNav4 = false, isNav5 = false, isIE6 = false strSeperator = "/"; var
// 1 = mm/dd/yyyy
// 2 = yyyy/dd/mm (Unable to do date check at this time)
// 3 = dd/mm/yyyy
vDateType = 3; // Global value for type of date formatvar vYearType = 4; //Set to 2 or 4 for number of digits in the year for Netscapevar vYearLength = 2; // Set to 4 if you want to force the user to enter 4 digits for the year before validating.var err = 0; // Set the error code to a default of zeroif(navigator.appName == "Netscape") {if
isNav4 =
isNav5 =
}
(navigator.appVersion < "5") {true;false;else
if
isNav4 =
isNav5 =
}
}
(navigator.appVersion > "4") {false;true;else
isIE6 =
}
{true;function
vDateType = dateType;
DateFormat(vDateName, vDateValue, e, dateCheck, dateType) {// vDateName = object name
// vDateValue = value in the field being checked
// e = event
// dateCheck
// True = Verify that the vDateValue is a valid date
// False = Format values being entered into vDateValue only
// vDateType
// 1 = mm/dd/yyyy
// 2 = yyyy/mm/dd
// 3 = dd/mm/yyyy
//Enter a tilde sign for the first number and you can check the variable information.
if
alert(
vDateName.value =
vDateName.focus();
(vDateValue == "~") {"AppVersion = "+navigator.appVersion+" \nNav. 4 Version = "+isNav4+" \nNav. 5 Version = "+isNav5+" \nIE Version = "+isIE6+" \nYear Type = "+vYearType+" \nDate Type = "+vDateType+" \nSeparator = "+strSeperator);"";return
}
true;var whichCode = (window.Event) ? e.which : e.keyCode;// Check to see if a seperator is already present.
// bypass the date if a seperator is present and the length greater than 8
if (vDateValue.length > 8 && isNav4) {if ((vDateValue.indexOf("-") >= 1) || (vDateValue.indexOf("/") >= 1))return
}
true;//Eliminate all the ASCII codes that are not validvar alphaCheck = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-";if (alphaCheck.indexOf(vDateValue) >= 1) {if
vDateName.value =
vDateName.focus();
vDateName.select();
(isNav4) {"";return
}
false;else
vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
{return
}
}
false;if (whichCode == 8) //Ignore the Netscape value for backspace. IE has no valuereturn false;else {//Create numeric string values for 0123456789/
//The codes provided include both keyboard and keypad values
var strCheck = '47,48,49,50,51,52,53,54,55,56,57,58,59,95,96,97,98,99,100,101,102,103,104,105';if (strCheck.indexOf(whichCode) != -1) {if (isNav4) {if
alert(
vDateName.value =
vDateName.focus();
vDateName.select();
(((vDateValue.length < 6 && dateCheck) || (vDateValue.length == 7 && dateCheck)) && (vDateValue.length >=1)) {"Invalid Date\nPlease Re-Enter");"";return
}
false;if (vDateValue.length == 6 && dateCheck) {var mDay = vDateName.value.substr(2,2);var mMonth = vDateName.value.substr(0,2);var mYear = vDateName.value.substr(4,4)//Turn a two digit year into a 4 digit yearif (mYear.length == 2 && vYearType == 4) {var mToday = new Date();//If the year is greater than 30 years from now use 19, otherwise use 20var checkYear = mToday.getFullYear() + 30; var mCheckYear = '20' + mYear;if
mYear =
(mCheckYear >= checkYear)'19' + mYear;elsemYear =
}
'20' + mYear;var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;if
alert(
vDateName.value =
vDateName.focus();
vDateName.select();
(!dateValid(vDateValueCheck)) {"Invalid Date\nPlease Re-Enter");"";return
}
false;return
}
true;else {// Reformat the date for validation and set date type to a 1if (vDateValue.length >= 8 && dateCheck) {if (vDateType == 1) // mmddyyyy{var mDay = vDateName.value.substr(2,2);var mMonth = vDateName.value.substr(0,2);var
vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;
}
mYear = vDateName.value.substr(4,4)if (vDateType == 2) // yyyymmdd{var mYear = vDateName.value.substr(0,4)var mMonth = vDateName.value.substr(4,2);var
vDateName.value = mYear+strSeperator+mMonth+strSeperator+mDay;
}
mDay = vDateName.value.substr(6,2);if (vDateType == 3) // ddmmyyyy{var mMonth = vDateName.value.substr(2,2);var mDay = vDateName.value.substr(0,2);var
vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
}
mYear = vDateName.value.substr(4,4)//Create a temporary variable for storing the DateType and change
//the DateType to a 1 for validation.
var
vDateType = 1;
vDateTypeTemp = vDateType;var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;if
alert(
vDateType = vDateTypeTemp;
vDateName.value =
vDateName.focus();
vDateName.select();
(!dateValid(vDateValueCheck)) {"Invalid Date\nPlease Re-Enter");"";return
}
vDateType = vDateTypeTemp;
false;return
}
true;else {if
alert(
vDateName.value =
vDateName.focus();
vDateName.select();
(((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {"Invalid Date\nPlease Re-Enter");"";return
}
}
}
}
false;else {// Non isNav Checkif
alert(
vDateName.value =
vDateName.focus();
(((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {"Invalid Date\nPlease Re-Enter");"";return
}
true;// Reformat date to format that can be validated. mm/dd/yyyyif (vDateValue.length >= 8 && dateCheck) {// Additional date formats can be entered here and parsed out to
// a valid date format that the validation routine will recognize.
if (vDateType == 1) // mm/dd/yyyy{var mMonth = vDateName.value.substr(0,2);var mDay = vDateName.value.substr(3,2);var
}
mYear = vDateName.value.substr(6,4)if (vDateType == 2) // yyyy/mm/dd{var mYear = vDateName.value.substr(0,4)var mMonth = vDateName.value.substr(5,2);var
}
mDay = vDateName.value.substr(8,2);if (vDateType == 3) // dd/mm/yyyy{var mDay = vDateName.value.substr(0,2);var mMonth = vDateName.value.substr(3,2);var
}
mYear = vDateName.value.substr(6,4)if (vYearLength == 4) {if
alert(
vDateName.value =
vDateName.focus();
(mYear.length < 4) {"Invalid Date\nPlease Re-Enter");"";return
}
}
true;// Create temp. variable for storing the current vDateTypevar vDateTypeTemp = vDateType;// Change vDateType to a 1 for standard date format for validation
// Type will be changed back when validation is completed.
vDateType = 1;// Store reformatted date to new variable for validation.var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;if (mYear.length == 2 && vYearType == 4 && dateCheck) {//Turn a two digit year into a 4 digit yearvar mToday = new Date();//If the year is greater than 30 years from now use 19, otherwise use 20var checkYear = mToday.getFullYear() + 30; var mCheckYear = '20' + mYear;if
mYear =
(mCheckYear >= checkYear)'19' + mYear;elsemYear =
vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
'20' + mYear;// Store the new value back to the field. This function will
// not work with date type of 2 since the year is entered first.
if (vDateTypeTemp == 1) // mm/dd/yyyyvDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;if (vDateTypeTemp == 3) // dd/mm/yyyyvDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
}
if
alert(
vDateType = vDateTypeTemp;
vDateName.value =
vDateName.focus();
(!dateValid(vDateValueCheck)) {"Invalid Date\nPlease Re-Enter");"";return
}
vDateType = vDateTypeTemp;
true;return
}
true;else {if (vDateType == 1) {if
vDateName.value = vDateValue+strSeperator;
}
(vDateValue.length == 2) {if
vDateName.value = vDateValue+strSeperator;
}
}
(vDateValue.length == 5) {if (vDateType == 2) {if
vDateName.value = vDateValue+strSeperator;
}
(vDateValue.length == 4) {if
vDateName.value = vDateValue+strSeperator;
}
}
(vDateValue.length == 7) {if (vDateType == 3) {if
vDateName.value = vDateValue+strSeperator;
}
(vDateValue.length == 2) {if
vDateName.value = vDateValue+strSeperator;
}
}
(vDateValue.length == 5) {return
}
}
true;if (vDateValue.length == 10&& dateCheck) {if (!dateValid(vDateName)) {// Un-comment the next line of code for debugging the dateValid() function error messages
//alert(err);
alert(
vDateName.focus();
vDateName.select();
}
}
"Invalid Date\nPlease Re-Enter");return
}
false;else {// If the value is not in the string return the string minus the last
// key entered.
if
vDateName.value =
vDateName.focus();
vDateName.select();
(isNav4) {"";return
}
false;else{
vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
return
}
}
}
}
false;function dateValid(objName) {var strDate;var strDateArray;var strDay;var strMonth;var strYear;var intday;var intMonth;var intYear;var booFound = false;var datefield = objName;var strSeparatorArray = new Array("-"," ","/",".");var intElementNr;// var err = 0;var
strMonthArray[0] =
strMonthArray[1] =
strMonthArray[2] =
strMonthArray[3] =
strMonthArray[4] =
strMonthArray[5] =
strMonthArray[6] =
strMonthArray[7] =
strMonthArray[8] =
strMonthArray[9] =
strMonthArray[10] =
strMonthArray[11] =
strMonthArray = new Array(12);"Jan";"Feb";"Mar";"Apr";"May";"Jun";"Jul";"Aug";"Sep";"Oct";"Nov";"Dec";//strDate = datefield.value;strDate = objName;if (strDate.length < 1) {return
}
true;for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {if
strDateArray = strDate.split(strSeparatorArray[intElementNr]);
(strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {if
err = 1;
(strDateArray.length != 3) {return
}
false;else
strDay = strDateArray[0];
strMonth = strDateArray[1];
strYear = strDateArray[2];
}
booFound =
}
}
{true;if (booFound == false) {if
strDay = strDate.substr(0, 2);
strMonth = strDate.substr(2, 2);
strYear = strDate.substr(4);
}
}
(strDate.length>5) {//Adjustment for short years enteredif
strYear =
}
strTemp = strDay;
strDay = strMonth;
strMonth = strTemp;
intday = parseInt(strDay, 10);
(strYear.length == 2) {'20' + strYear;if
err = 2;
(isNaN(intday)) {return
}
intMonth = parseInt(strMonth, 10);
false;if (isNaN(intMonth)) {for (i = 0;i<12;i++) {if
intMonth = i+1;
strMonth = strMonthArray[i];
i = 12;
}
}
(strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {if
err = 3;
(isNaN(intMonth)) {return
}
}
intYear = parseInt(strYear, 10);
false;if
err = 4;
(isNaN(intYear)) {return
}
false;if
err = 5;
(intMonth>12 || intMonth<1) {return
}
false;if
err = 6;
((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {return
}
false;if
err = 7;
((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {return
}
false;if (intMonth == 2) {if
err = 8;
(intday < 1) {return
}
false;if (LeapYear(intYear) == true) {if
err = 9;
(intday > 29) {return
}
}
false;else {if
err = 10;
(intday > 28) {return
}
}
}
false;return
}
true;function LeapYear(intYear) {if (intYear % 100 == 0) {if
}
(intYear % 400 == 0) { return true; }else {if
}
((intYear % 4) == 0) { return true; }return
}
false;function chkdate2(){var today = new Date();var
ln1=ln1.substr(3,2)+
ln1=document.f1.fromdate.value;'/'+ln1.substr(0,2)+ln1.substr(5,5);var

{
alert(
document.f1.fromdate.focus ();
document.f1.fromdate.value=

}


}
ln=new Date(ln1);if ( ln > today ) "Sanction Date should be less than today's date");"";return false;return true;function chkdate3(){var today = new Date();var
ln1=ln1.substr(3,2)+
ln1=document.f1.todate.value;'/'+ln1.substr(0,2)+ln1.substr(5,5);var

{
alert(
document.f1.todate.focus ();
document.f1.todate.value=

}


}

<
function
{
popUpCalendar(SourceControl, DestinationControl,

}
ln=new Date(ln1);if ( ln > today ) "Sanction Date should be less than today's date");"";return false;return true;</script>script language="javascript" type="text/javascript"> ShhowCalendar(SourceControl,DestinationControl)"dd/mm/yyyy");return false;</script><script language="javascript" type="text/javascript">// Check browser versionvar
var
isNav4 = false, isNav5 = false, isIE6 = false strSeperator = "/"; var
// 1 = mm/dd/yyyy
// 2 = yyyy/dd/mm (Unable to do date check at this time)
// 3 = dd/mm/yyyy
vDateType = 3; // Global value for type of date formatvar vYearType = 4; //Set to 2 or 4 for number of digits in the year for Netscapevar vYearLength = 2; // Set to 4 if you want to force the user to enter 4 digits for the year before validating.var err = 0; // Set the error code to a default of zeroif(navigator.appName == "Netscape") {if
isNav4 =
isNav5 =
}
(navigator.appVersion < "5") {true;false;else
if
isNav4 =
isNav5 =
}
}
(navigator.appVersion > "4") {false;true;else
isIE6 =
}
{true;function
vDateType = dateType;
DateFormat(vDateName, vDateValue, e, dateCheck, dateType) {// vDateName = object name
// vDateValue = value in the field being checked
// e = event
// dateCheck
// True = Verify that the vDateValue is a valid date
// False = Format values being entered into vDateValue only
// vDateType
// 1 = mm/dd/yyyy
// 2 = yyyy/mm/dd
// 3 = dd/mm/yyyy
//Enter a tilde sign for the first number and you can check the variable information.
if
alert(
vDateName.value =
vDateName.focus();
(vDateValue == "~") {"AppVersion = "+navigator.appVersion+" \nNav. 4 Version = "+isNav4+" \nNav. 5 Version = "+isNav5+" \nIE Version = "+isIE6+" \nYear Type = "+vYearType+" \nDate Type = "+vDateType+" \nSeparator = "+strSeperator);"";return
}
true;var whichCode = (window.Event) ? e.which : e.keyCode;// Check to see if a seperator is already present.
// bypass the date if a seperator is present and the length greater than 8
if (vDateValue.length > 8 && isNav4) {if ((vDateValue.indexOf("-") >= 1) || (vDateValue.indexOf("/") >= 1))return
}
true;//Eliminate all the ASCII codes that are not validvar alphaCheck = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-";if (alphaCheck.indexOf(vDateValue) >= 1) {if
vDateName.value =
vDateName.focus();
vDateName.select();
(isNav4) {"";return
}
false;else
vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
{return
}
}
false;if (whichCode == 8) //Ignore the Netscape value for backspace. IE has no valuereturn false;else {//Create numeric string values for 0123456789/
//The codes provided include both keyboard and keypad values
var strCheck = '47,48,49,50,51,52,53,54,55,56,57,58,59,95,96,97,98,99,100,101,102,103,104,105';if (strCheck.indexOf(whichCode) != -1) {if (isNav4) {if
alert(
vDateName.value =
vDateName.focus();
vDateName.select();
(((vDateValue.length < 6 && dateCheck) || (vDateValue.length == 7 && dateCheck)) && (vDateValue.length >=1)) {"Invalid Date\nPlease Re-Enter");"";return
}
false;if (vDateValue.length == 6 && dateCheck) {var mDay = vDateName.value.substr(2,2);var mMonth = vDateName.value.substr(0,2);var mYear = vDateName.value.substr(4,4)//Turn a two digit year into a 4 digit yearif (mYear.length == 2 && vYearType == 4) {var mToday = new Date();//If the year is greater than 30 years from now use 19, otherwise use 20var checkYear = mToday.getFullYear() + 30; var mCheckYear = '20' + mYear;if
mYear =
(mCheckYear >= checkYear)'19' + mYear;elsemYear =
}
'20' + mYear;var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;if
alert(
vDateName.value =
vDateName.focus();
vDateName.select();
(!dateValid(vDateValueCheck)) {"Invalid Date\nPlease Re-Enter");"";return
}
false;return
}
true;else {// Reformat the date for validation and set date type to a 1if (vDateValue.length >= 8 && dateCheck) {if (vDateType == 1) // mmddyyyy{var mDay = vDateName.value.substr(2,2);var mMonth = vDateName.value.substr(0,2);var
vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;
}
mYear = vDateName.value.substr(4,4)if (vDateType == 2) // yyyymmdd{var mYear = vDateName.value.substr(0,4)var mMonth = vDateName.value.substr(4,2);var
vDateName.value = mYear+strSeperator+mMonth+strSeperator+mDay;
}
mDay = vDateName.value.substr(6,2);if (vDateType == 3) // ddmmyyyy{var mMonth = vDateName.value.substr(2,2);var mDay = vDateName.value.substr(0,2);var
vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
}
mYear = vDateName.value.substr(4,4)//Create a temporary variable for storing the DateType and change
//the DateType to a 1 for validation.
var
vDateType = 1;
vDateTypeTemp = vDateType;var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;if
alert(
vDateType = vDateTypeTemp;
vDateName.value =
vDateName.focus();
vDateName.select();
(!dateValid(vDateValueCheck)) {"Invalid Date\nPlease Re-Enter");"";return
}
vDateType = vDateTypeTemp;
false;return
}
true;else {if
alert(
vDateName.value =
vDateName.focus();
vDateName.select();
(((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {"Invalid Date\nPlease Re-Enter");"";return
}
}
}
}
false;else {// Non isNav Checkif
alert(
vDateName.value =
vDateName.focus();
(((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {"Invalid Date\nPlease Re-Enter");"";return
}
true;// Reformat date to format that can be validated. mm/dd/yyyyif (vDateValue.length >= 8 && dateCheck) {// Additional date formats can be entered here and parsed out to
// a valid date format that the validation routine will recognize.
if (vDateType == 1) // mm/dd/yyyy{var mMonth = vDateName.value.substr(0,2);var mDay = vDateName.value.substr(3,2);var
}
mYear = vDateName.value.substr(6,4)if (vDateType == 2) // yyyy/mm/dd{var mYear = vDateName.value.substr(0,4)var mMonth = vDateName.value.substr(5,2);var
}
mDay = vDateName.value.substr(8,2);if (vDateType == 3) // dd/mm/yyyy{var mDay = vDateName.value.substr(0,2);var mMonth = vDateName.value.substr(3,2);var
}
mYear = vDateName.value.substr(6,4)if (vYearLength == 4) {if
alert(
vDateName.value =
vDateName.focus();
(mYear.length < 4) {"Invalid Date\nPlease Re-Enter");"";return
}
}
true;// Create temp. variable for storing the current vDateTypevar vDateTypeTemp = vDateType;// Change vDateType to a 1 for standard date format for validation
// Type will be changed back when validation is completed.
vDateType = 1;// Store reformatted date to new variable for validation.var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;if (mYear.length == 2 && vYearType == 4 && dateCheck) {//Turn a two digit year into a 4 digit yearvar mToday = new Date();//If the year is greater than 30 years from now use 19, otherwise use 20var checkYear = mToday.getFullYear() + 30; var mCheckYear = '20' + mYear;if
mYear =
(mCheckYear >= checkYear)'19' + mYear;elsemYear =
vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
'20' + mYear;// Store the new value back to the field. This function will
// not work with date type of 2 since the year is entered first.
if (vDateTypeTemp == 1) // mm/dd/yyyyvDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;if (vDateTypeTemp == 3) // dd/mm/yyyyvDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
}
if
alert(
vDateType = vDateTypeTemp;
vDateName.value =
vDateName.focus();
(!dateValid(vDateValueCheck)) {"Invalid Date\nPlease Re-Enter");"";return
}
vDateType = vDateTypeTemp;
true;return
}
true;else {if (vDateType == 1) {if
vDateName.value = vDateValue+strSeperator;
}
(vDateValue.length == 2) {if
vDateName.value = vDateValue+strSeperator;
}
}
(vDateValue.length == 5) {if (vDateType == 2) {if
vDateName.value = vDateValue+strSeperator;
}
(vDateValue.length == 4) {if
vDateName.value = vDateValue+strSeperator;
}
}
(vDateValue.length == 7) {if (vDateType == 3) {if
vDateName.value = vDateValue+strSeperator;
}
(vDateValue.length == 2) {if
vDateName.value = vDateValue+strSeperator;
}
}
(vDateValue.length == 5) {return
}
}
true;if (vDateValue.length == 10&& dateCheck) {if (!dateValid(vDateName)) {// Un-comment the next line of code for debugging the dateValid() function error messages
//alert(err);
alert(
vDateName.focus();
vDateName.select();
}
}
"Invalid Date\nPlease Re-Enter");return
}
false;else {// If the value is not in the string return the string minus the last
// key entered.
if
vDateName.value =
vDateName.focus();
vDateName.select();
(isNav4) {"";return
}
false;else{
vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
return
}
}
}
}
false;function dateValid(objName) {var strDate;var strDateArray;var strDay;var strMonth;var strYear;var intday;var intMonth;var intYear;var booFound = false;var datefield = objName;var strSeparatorArray = new Array("-"," ","/",".");var intElementNr;// var err = 0;var
strMonthArray[0] =
strMonthArray[1] =
strMonthArray[2] =
strMonthArray[3] =
strMonthArray[4] =
strMonthArray[5] =
strMonthArray[6] =
strMonthArray[7] =
strMonthArray[8] =
strMonthArray[9] =
strMonthArray[10] =
strMonthArray[11] =
strMonthArray = new Array(12);"Jan";"Feb";"Mar";"Apr";"May";"Jun";"Jul";"Aug";"Sep";"Oct";"Nov";"Dec";//strDate = datefield.value;strDate = objName;if (strDate.length < 1) {return
}
true;for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {if
strDateArray = strDate.split(strSeparatorArray[intElementNr]);
(strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {if
err = 1;
(strDateArray.length != 3) {return
}
false;else
strDay = strDateArray[0];
strMonth = strDateArray[1];
strYear = strDateArray[2];
}
booFound =
}
}
{true;if (booFound == false) {if
strDay = strDate.substr(0, 2);
strMonth = strDate.substr(2, 2);
strYear = strDate.substr(4);
}
}
(strDate.length>5) {//Adjustment for short years enteredif
strYear =
}
strTemp = strDay;
strDay = strMonth;
strMonth = strTemp;
intday = parseInt(strDay, 10);
(strYear.length == 2) {'20' + strYear;if
err = 2;
(isNaN(intday)) {return
}
intMonth = parseInt(strMonth, 10);
false;if (isNaN(intMonth)) {for (i = 0;i<12;i++) {if
intMonth = i+1;
strMonth = strMonthArray[i];
i = 12;
}
}
(strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {if
err = 3;
(isNaN(intMonth)) {return
}
}
intYear = parseInt(strYear, 10);
false;if
err = 4;
(isNaN(intYear)) {return
}
false;if
err = 5;
(intMonth>12 || intMonth<1) {return
}
false;if
err = 6;
((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {return
}
false;if
err = 7;
((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {return
}
false;if (intMonth == 2) {if
err = 8;
(intday < 1) {return
}
false;if (LeapYear(intYear) == true) {if
err = 9;
(intday > 29) {return
}
}
false;else {if
err = 10;
(intday > 28) {return
}
}
}
false;return
}
true;function LeapYear(intYear) {if (intYear % 100 == 0) {if
}
(intYear % 400 == 0) { return true; }else {if
}
((intYear % 4) == 0) { return true; }return
}
false;function chkdate2(){var today = new Date();var
ln1=ln1.substr(3,2)+
ln1=document.f1.fromdate.value;'/'+ln1.substr(0,2)+ln1.substr(5,5);var

{
alert(
document.f1.fromdate.focus ();
document.f1.fromdate.value=

}


}
ln=new Date(ln1);if ( ln > today ) "Sanction Date should be less than today's date");"";return false;return true;function chkdate3(){var today = new Date();var
ln1=ln1.substr(3,2)+
ln1=document.f1.todate.value;'/'+ln1.substr(0,2)+ln1.substr(5,5);var

{
alert(
document.f1.todate.focus ();
document.f1.todate.value=

}


}


On asp Page body section put the text box like.


<


input class="style2" name="fromdate1" onclick="ShhowCalendar(fromdate,fromdate);" onfocus="javascript:vDateType='3'" onkeyup="DateFormat(this,this.value,event,false,'3')" type="text" value="" />
ln=new Date(ln1);if ( ln > today ) "Sanction Date should be less than today's date");"";return false;return true;</script>

<
function
{
popUpCalendar(SourceControl, DestinationControl,

}