我把一个js写在js 文件夹下,并且重名为index1.js
可是在前台页面调用的时候老出错误。具体代码如下
显示页面是:
<link rel="stylesheet" href='css/style.css' type="text/css">
<script language="JavaScript" src="/js/index1.js"></script>
<form id="form1" name="Form1" method="post" action="index_add1.php">
<table width="60%" height="67" border="0" align="center" cellpadding="0" cellspacing="1" bordercolor="#CCCCCC" bgcolor="#CCCCCC">
  <tr >
    <td width="172" height="36" bgcolor="#FFFFFF" class="title_nows">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注册账户:</td>
    <td width="572" bgcolor="#FFFFFF">&nbsp;&nbsp;
      <input name="new_name"  type="text"   class="center"/></td>
  </tr>
  <tr>
    <td height="27" colspan="2" bgcolor="#FFFFFF">
      <div align="center">
        <input   type="button" value="用户提交"  class="tt_top" onclick="check()"/>
        </div></td>
    </tr>
</table>
</form><script language="JavaScript" src="/js/index1.js"></script>
这句是调用js文件的语句
js里面的内容如下:
<script LANGUAGE="JavaScript"> 
function check() 
{ if (document.Form1.new_name.value == "") 

alert("请填写您的用户名?"); 
document.Form1.new_name.focus(); 
return (false); 
} var filter=/^\s*[.A-Za-z0-9_-]{5,15}\s*$/; 
if (!filter.test(document.Form1.new_name.value)) { 
alert("用户名填写不正确,请重新填写!可使用的字符为(A-Z a-z 0-9 _ - .)长度不小?5个字符,不超?15个字符,注意不要使用空格?"); 
document.Form1.new_name.focus(); 
document.Form1.new_name.select(); 
return (false); 

document.Form1.submit() 

</script> 
但当我把JS文件方在同一个页面的时候就能执行,并且有提示