Monday, May 23, 2011

To display clock via javscript..

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!
<
<
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">html xmlns="http://www.w3.org/1999/xhtml">head runat="server"><title>Untitled Page</title><script type="text/javascript" language="javascript">
{


function updateTime()var label = document.getElementById('currentTime');if (label) {var time = new Date();// var time = (new Date()).localeFormat("T");label.innerHTML = time;
}
}
updateTime();
window.setInterval(updateTime, 1000);

</
<
</script>head>body><form id="form1" runat="server"><div><span id="currentTime" style="font-size: xx-large; font-weight: bold; line-height: 40px;">4:35:45 AM</span></div>
</
</
</form>body>html>

Wednesday, February 10, 2010

How to Replace '&' to '&' in Javascript.

<html>
<body>
<script type="text/javascript">
var str= "&amp;";
alert(str);
str= str.replace(/\&amp;/g,'&');
alert(str);
</script>
</body>
</html>

Wednesday, February 3, 2010

Javascript RegEx - to check whether a string contain numeric value or not.

<script type="text/javascript">
//matches any non-digit in string
var patt1=/\D/;

document.write(patt1.test(""));
document.write("\n");
document.write(patt1.test("@"));
document.write("\n");
document.write(patt1.test("A"));
document.write("\n");
document.write(patt1.test("AAA"));
document.write("\n");
document.write(patt1.test("1"));
document.write("\n");
document.write(patt1.test("111"));
document.write("\n");
document.write(patt1.test("AA111"));
document.write("\n");
</script>
</body>
</html>

Try It
More Regex Patterns