Thursday, August 23, 2007
Remove Space At Beginning Of The String Using Regular Expression (Left Trim)
<head>
<script language="javascript">
function Right_Trim()
{
var str = document.getElementById('txt1').value;
str = str.replace(/^\s+/g,'');
document.getElementById('txt1').value = str;
document.getElementById('txt1').focus();
}
</script>
</head>
<body>
<input type='text' id='txt1' value=' Click To Check' />
<input type='button' id='bt1' value='Remove Space At Beginning Of The String' onclick='Right_Trim();' />
</body>
</html>
Wednesday, August 22, 2007
Removing The White Space In The String At The End Using Regular Expression (Right Trim)
<head>
<script language="javascript">
function Left_Trim()
{
var str = document.getElementById('txt1').value;
alert(str.length);// Alert To Show The Length Of The String Before Removing White Space
str = str.replace(/\s+$/g,'');
alert(str.length); // Alert To Show The Length Of The String After Removing White Space
document.getElementById('txt1').value = str;
document.getElementById('txt1').focus();
}
</script>
</head>
<body>
<input type='text' id='txt1' value='Click To Check ' /> <input type='button' id='bt1' value='Remove Space At End Of The String' onclick='Left_Trim();' />
</body>
</html>
Friday, August 17, 2007
Trap F1 key in IE, ByPass Showing Help Window
<html>
<head>
<script>
function ByPass()
{
var kCode = window.event.keyCode;
if(kCode == 112)
{
alert('F1 Clicked'); // Alter Code As Your Wish
}
}
</script>
</head>
<body onhelp="return false;" onkeydown="ByPass()">
</body>
</html>
Note: Tested In IE 7
Wednesday, August 15, 2007
60 years of Freedom - Happy Indian Independence Day
Listen Vande Mataram Online
Saturday, August 11, 2007
Setting Up | Changing the default browser used in VS 2005
1) Right click on a .aspx page in your solution explorer
2) Select the "browse with" context menu option
Step 2.1:Browser Dialog Will displayed in screen.
Friday, August 10, 2007
JavaScript Program To Display Date and Current Time
<head>
<script type="text/javascript">
function TickTick()
{
var today=new Date()
var dd = today.getDate();
var mm = today.getMonth();
var yy = today.getFullYear();
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()
m=secTicker(m)
s=secTicker(s)
document.getElementById('Clock').innerHTML="<strong>"+dd+"-"+mm+"-"+yy+" (dd/mm/yyyy)<br/>"+h+":"+m+":"+s+"</strong>";
t=setTimeout('TickTick()',1000)
}
function secTicker(i)// This Function is to add zero before minutes and second value which is less than 10
{
if (i < 10){i = "0" + i}return i; }
</script>
</head>
<body onload="TickTick()">
<div id="Clock"></div>
</body>
</html>
OutPut
Thursday, August 9, 2007
Date() Object In JavaScript
Dates and times creates a series of special problems to the computer programming particularly Web programmer who has to supply web Content to a global audience. For Example:Some countries present the date as dd/mm/yy while others use mm/dd/yy.
In JavaScript Date Object is a part of the overall specification of JavaScript and is available to any page that can include JavaScript,you create a new date object instance by creating a variable as follows: dtObj = new Date( );
The Date( ) object doesn't have properties that can be directly read and written. Instead it has methods that are used to work with the data value in the object.
Program:
<html>
<head>
<title>Date Object In JavaScript</title>
</head>
<body>
<script language="javascript">
dtObj = new Date();
document.write
("Return the day of the month "+"("+dtObj.getDate( )+")"+".<br/><br/>");
// O/P Will Be == > Return the day of the month 9
document.write
("Return the day of the week "+"("+dtObj.getDay( )+")"+ ".<br/><br/>");
// O/P Will Be == > Return the day of the week 4.
document.write
("Return the four digit year "+"("+dtObj.getFullYear( )+")"+ ".<br/><br/>");
// O/P Will Be == > Return the four digit year 2007.
document.write
("Return the hours "+"("+dtObj.getHours( )+")"+ ".<br/><br/>");
// O/P Will Be == > Return the hours 18.
document.write
("Return the milliseconds "+"("+dtObj.getMilliseconds( )+")"+ ".<br/><br/>");
// O/P Will Be == > Return the milliseconds 125.
document.write
("Return the minutes "+"("+dtObj.getMinutes( )+")"+ ".<br/><br/>");
// O/P Will Be == > Return the minutes 29.
document.write
("Return the month "+"("+dtObj.getMonth( )+")" + ".<br/><br/>");
// O/P Will Be == > Return the month 7.
document.write
("Return the seconds "+"("+dtObj.getSeconds( )+")" + ".<br/><br/>");
// O/P Will Be == > Return the seconds 17
document.write
("Return the internal representation of the time "+"("+dtObj.getTime( )
+")"+ ".<br/><br/>");
// O/P Will Be == > Return the internal representation of the time 1186664357125.
document.write
("Return the offset from GMT "+"("+dtObj.getTimezoneOffset( ) +")"+ ".<br/><br/>");
// O/P Will Be == > Return the offset from GMT -330.
document.write
("Return the Universal Time day of the month "+"("+dtObj.getUTCDate( )+")" + ".<br/><br/>");
// O/P Will Be == > Return the Universal Time day of the month 9.
document.write
("Return the Universal Time day of the week "+"("+dtObj.getUTCDay( )+")"+ ".<br/><br/>");
// O/P Will Be == > Return the Universal Time day of the week 4.
document.write
("Return the Universal Time four digit year "+"("+dtObj.getUTCFullYear( )+")" + ".<br/><br/>");
// O/P Will Be == > Return the Universal Time four digit year 2007.
document.write
("Return the Universal Time hours "+"("+dtObj.getUTCHours( )+")" + ".<br/><br/>");
// O/P Will Be == > Return the Universal Time hours 12.
document.write
("Return the Universal Time milliseconds "+"("+dtObj.getUTCMilliseconds( )+")" + ".<br/><br/>");
// O/P Will Be == > Return the Universal Time milliseconds 125.
document.write
("Return the Universal Time minutes "+"("+dtObj.getUTCMinutes( ) +")"+ ".<br/><br/>");
// O/P Will Be == > Return the Universal Time minutes 59.
document.write
("Return the Universal Time month "+"("+dtObj.getUTCMonth( )+")"+ ".<br/><br/>");
// O/P Will Be == > Return the Universal Time month 7.
document.write
("Return the Universal Time seconds "+"("+dtObj.getUTCSeconds( )+")"+".<br/><br/>");
// O/P Will Be == > Return the Universal Time seconds 17.
document.write
("The time and date at Your computer's location "+"("+dtObj.toLocaleString()+")" + ".<br/><br/>");
//The time and date at Your computer's location Thursday, August 09, 2007 6:29:17 PM.
document.write
("The time zone offset B/W local time and GMT is "+"("+dtObj.getTimezoneOffset()+")" + " minutes.<br/><br/>");
//The time zone offset B/W local time and GMT is -330 minutes.
document.write
("The time and date (GMT) is: "+"("+dtObj.toGMTString()+")" + ".<br/><br/>");
//The time and date (GMT) is: Thu, 9 Aug 2007 12:59:17 UTC.
</script>
</body>
</html>
Note: Output In Coment Line are which i got as result when i Compiled in My System, so date and time will change according your system time and day.
Sunday, August 5, 2007
Dynamically Increase The Size Of The TextBox Using JavaScript
<head>
<script>
function incr()
{
var len = document.getElementById('txt').value;
document.getElementById('txt').style.width = 75+len.length*4+'px';
}
</script>
<body>
<input type='text' id='txt' onkeydown='incr()' style='width:75px' />
</body>
</html>
Friday, August 3, 2007
Remove White Space In String Using Regular Expression in JavaScript
<head>
<script language="javascript">
function rmWhiteSpace()
{
var str = document.getElementById('txt1').value;
str = str.replace(/\s+/g,'');
document.getElementById('txt1').value = str;
// \s+ Description
// + 1 or more of previous expression.
// \s Matches any white-space character.
// Equivalent to the Unicode character categories [\f\n\r\t\v\x85\p{Z}].
// If ECMAScript-compliant behavior is specified with the ECMAScript option,
// \s is equivalent to [ \f\n\r\t\v].
}
</script>
</head>
<body>
<input type='text' id='txt1' value=' Click To Check' /> <input type='button' id='bt1' value='Remove White Space' onclick='rmWhiteSpace();' />
</body>
</html>
Program Demo
OutPut