Sunday, November 13, 2011

Different Test Style By Java Script.

Hi,
Java script provide different in built function for editing the output of Test Format like.
<html>
<body>

<script type="text/javascript">

var txt = "Hello World!";

document.write("<p>Big: " + txt.big() + "</p>");
document.write("<p>Small: " + txt.small() + "</p>");

document.write("<p>Bold: " + txt.bold() + "</p>");
document.write("<p>Italic: " + txt.italics() + "</p>");

document.write("<p>Fixed: " + txt.fixed() + "</p>");
document.write("<p>Strike: " + txt.strike() + "</p>");

document.write("<p>Fontcolor: " + txt.fontcolor("green") + "</p>");
document.write("<p>Fontsize: " + txt.fontsize(6) + "</p>");

document.write("<p>Subscript: " + txt.sub() + "</p>");
document.write("<p>Superscript: " + txt.sup() + "</p>");

document.write("<p>Link: " + txt.link("http://www.w3schools.com") + "</p>");

document.write("<p>Blink: " + txt.blink() + " (does not work in IE, Chrome, or Safari)</p>");

</script>

</body>
</html>

Just try this and I hope you will got some new.

Wednesday, November 9, 2011

How to convert Xml in to Html (xHtml)

Hi today i got the idea how we can convert our xml page in to xhtml . Its quit simple as just like  css style sheet is uses to decorate html page.
The major different in the process just here we are use xsl (xml style sheet ) instead css. This can be done by the help of  Xslt (xml style sheet transformation ).
Here i am post the example (Its a xml page where we give href relation with xsl plae like.

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?>
<catalog>
  <cd>
    <title>Empire Burlesque</title>
    <artist>Bob Dylan</artist>
    <country>USA</country>
    <company>Columbia</company>
    <price>10.90</price>
    <year>1985</year>
  </cd>
</catalog>
And the code of  cdcatalog.xsl is here
<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
  <html>
  <body>
  <h2>My CD Collection</h2>
  <table border="1">
    <tr bgcolor="#9acd32">
      <th>Title</th>
      <th>Artist</th>
    </tr>
    <xsl:for-each select="catalog/cd">
    <tr>
      <td><xsl:value-of select="title"/></td>
      <td><xsl:value-of select="artist"/></td>
    </tr>
    </xsl:for-each>
  </table>
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>
The reference of style sheet already given in the top header of xml page.

 <xsl:template match="/"> :-- Describe that we are apply style sheet in whole xml page due to match attribute match="/"


<xsl:for-each select="catalog/cd"> :-- Its reach all the nodes under the catalog .

Hi.... an another example of Converting xml in to Html
My Student.xml page code
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="student.xsl"?>

<student>
          <Roll_number>
                        <Name>Deepak Sharma</Name>
                        <Class>5th</Class>
                        <Year>2010</Year>  
          </Roll_number>
          <Roll_number>
                        <Name>Arun Sharma</Name>
                        <Class>5th</Class>
                        <Year>2011</Year>  
          </Roll_number>
          <Roll_number>
                        <Name>Mohit Sharma</Name>
                        <Class>5th</Class>
                        <Year>2010</Year>  
          </Roll_number>

</student>
Just check it that i have already mention student.xsl in there head session.
The code of student.xsl is.....
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
          <table><tr>
                 <th>Name</th><th>Class</th></tr>
                  <xsl:for-each select="student/Roll_number">
                 <tr><td><xsl:value-of select="Name"/></td><td><xsl:value-of select="Year"/></td></tr>
                 </xsl:for-each>
          </table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The xml style sheet flow chat like that....
1.<xsl:stylesheet version="" href="" ?></xsl:stylesheet>
2.<xsl:template></xsl:template>
3.<xsl:for-each></xsl:for-each>
4.<xsl:value-of select="">
Thanks




Tuesday, November 8, 2011

What is Xml NameSpace

Hi
I am start with some xml example let check this out......
<table>
  <tr>
    <td>Apples</td>
    <td>Bananas</td>
  </tr>
</table>
And another example of xml is
<table>
  <name>African Coffee Table</name>
  <width>80</width>
  <length>120</length>
</table>
As per the example both xml tag start with Table tag . so when we combined to gather there may be the chance of conflict.
An XML parser will not know how to handle these differences.

We can resolve the problem by Tar prefix like 
<h:table>
  <h:tr>
    <h:td>Apples</h:td>
    <h:td>Bananas</h:td>
  </h:tr>
</h:table>

<f:table>
  <f:name>African Coffee Table</f:name>
  <f:width>80</f:width>
  <f:length>120</f:length>
</f:table> 
The namespace is defined by the xmlns(xml namespace) attribute in the start tag of an element.
The namespace declaration has the following syntax. xmlns:prefix="URI".

<h:table xmlns:h="http://www.w3.org/TR/html4/">
  <h:tr>
    <h:td>Apples</h:td>
    <h:td>Bananas</h:td>
  </h:tr>
</h:table>

<f:table xmlns:f="http://www.w3schools.com/furniture">
  <f:name>African Coffee Table</f:name>
  <f:width>80</f:width>
  <f:length>120</f:length>
</f:table>
When a namespace is defined for an element, all child elements with the same prefix are associated with the same namespace.
Namespaces can be declared in the elements where they are used or in the XML root element:
<root
xmlns:h="http://www.w3.org/TR/html4/"
xmlns:f="http://www.w3schools.com/furniture"
>

<h:table>
  <h:tr>
    <h:td>Apples</h:td>
    <h:td>Bananas</h:td>
  </h:tr>
</h:table>

<f:table>
  <f:name>African Coffee Table</f:name>
  <f:width>80</f:width>
  <f:length>120</f:length>
</f:table>

</root> 

Namespaces in Real Use

XSLT is an XML language that can be used to transform XML documents into other formats, like HTML.
In the XSLT document below, you can see that most of the tags are HTML tags.
The tags that are not HTML tags have the prefix xsl, identified by the namespace xmlns:xsl="http://www.w3.org/1999/XSL/Transform":

Thanks It all about xml namespace . I will  post further in our next session.



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,

}