81,092
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<script>
function check(){
var value=document.getElementById("path1").value;
var str=value.substring(value.lastIndexOf("\\")+1,value.length);
var regex=/^\d{4}年\d{1,2}[月|季度].*$/;
if(!regex.test(str)){
alert("error");
}else{
alert("success");
}
}
</script>
</head>
<body>
<input type="text" id="path1" value="C:\Documents and Settings\administrator\桌面\2010年2季度我的文档.doc"/><input type="button" value="验证" onclick="check()"/>
<br/>
<input type="text" id="path2" value="C:\Documents and Settings\administrator\桌面\2010年6月我的文档.doc"/><input type="button" value="验证" onclick="check()">
</body>
</html>