Friday, 23 March 2012

how to remove any character using javascript?

I am removing only " - (dash), . (dot), (space) in this exmple.

function dotrm(cit)
{
var cl=cit.length;
var ch=cit;
for(l=0;l<=cl;l++)
{
if(cit[l] == '.' || cit[l] == ' ' || cit[l]=='-')
{
ch=cit.replace(cit[l],'');
}
}
document.getElementById("city").value=ch;
}

No comments:

Post a Comment