javascript利用substr获取字符串的子串
<form name="form1" >
<input type="text" value="" name="f2" >
<input type="button" value="get" onclick="f()">
</form>
<script>
function f()
{
t=document.form1.f2.value;
alert(t.substr(0,2));//获取左边两个字符
alert(t.substr(t.length-2,t.length))//获取右边两个字符
alert(t.substr(2,t.length));//去掉字符串的左边两个字符串
}
</script>