javascript–左右補0
三月 16th, 2008
//呼叫左邊補0函式
padLeft(字串,補0長度)
//呼叫右邊補0函式
padRight(字串,補0長度)
function padLeft(str,lenght){
if(str.length >= lenght)
return str;
else
return padLeft("0" +str,lenght);
}
function padRight(str,lenght){
if(str.length >= lenght)
return str;
else
return padRight(str+"0",lenght);
}
Entry Filed under: asp.net(vb.net), JS
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed