Friday, January 4, 2008
Javascript : Allow only Numeric in Textbox
function validNum(o)
{
if(event.keyCode != 37 && event.keyCode != 39)
o.value = o.value.replace ( /[^0-9]/g, "" );
}
{
if(event.keyCode != 37 && event.keyCode != 39)
o.value = o.value.replace ( /[^0-9]/g, "" );
}
Convert string to TitleCase
string strSample = "MOHAN";
strResult = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(strSample.ToLower());
// Answer : strResult = "Mohan"
strResult = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(strSample.ToLower());
// Answer : strResult = "Mohan"
Javascript: Regular Expression to replace '-' to ','
function fnReplace()
{
var rExp = /-/gi;
var strX = '1,2,3,5-6,4-3-5-4';
alert(strX.replace(rExp,','));
}
{
var rExp = /-/gi;
var strX = '1,2,3,5-6,4-3-5-4';
alert(strX.replace(rExp,','));
}
Subscribe to:
Posts (Atom)