Thursday, November 20, 2008

Javascript: Making Initial Letter Capital for text box

Following script will work to make the initial letter in your text box automatically.

I have placed this in onKeyup event, you can use it according to your own requirements.


Here is the example:

Thursday, November 13, 2008

JavaScript: Function To Check Whether provided string contains some wildcard character

The following function returns true if the string value contains the specific wild-card character.


1- fieldValue -- String

It is a string that needs to be checked whether it contains some special/wildcard characters

2- wildChar -- String/ Single Char

It is a character that you want to search whether it is present in the string passed as first parameter of this function.

function containsWildCard(fieldValue, wildChar)
// var fieldValue = window.document.getElementById("fieldID").value;
if (fieldValue.split(wildChar).length > 1)
alert ("WildCard!");
return false;
alert ("No - WildCard!");
return true;


Monday, November 3, 2008

Javascript: Function To Get Currrent Time

function getCurrentTime()
var d = new Date();

var hour=d.getHours();
var minute=d.getMinutes();
var second=d.getSeconds();

hour = '0'+hour;
minute= '0'+minute;

second= '0'+second;

var time =hour+':'+minute+':'+second

return time;