很简单的东西,别人问了,写了顺便放着吧
格式为e:\test\ddf形式的就可以通过验证。
- <html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=gbk">
- <script language="Javascript">
- function verify()
- {
- var tt = document.getElementById("tt").value;
- var pattern = /^([a-zA-Z]){1}:(;
- flag = pattern.test(tt);
- if(flag)
- {
- alert("格式正确!");
- }
- else
- {
- alert("格式不对!");
- }
- }
- </script>
- </head>
- <body>
- <form id="myform">
- 请输入目录:
- <input id="tt" name="mulu" type="text" >
- <input type="button" value="test" οnclick="verify()">
- </form>
- </body>
- </html>
转载于:https://blog.51cto.com/huqianhao/954941