function  test()        
    {       
        var  d="<bean:message  key="welcome"/>";  
        if(document.userForm.loginName.value.length<1)       
       {       
             alert(d);       
             document.userForm.loginName.focus();       
             return  false;       
       }       
  }       javascript判断上传文件名不能包含中文和空格
<form   onsubmit="return   c(this)">   
  <input   type=file   name=ff>   
  <input   type=submit>   
  </form>   
  <script>   
  function   c(o)   
  {   
  str   =   o.ff.value.substr(o.ff.value.lastIndexOf("\\")+1)   
  if(/[   \u4e00-\u9fa5]/.test(str))   
  {   
  alert("不得中文,空格")   
  return   false   
  }   
  }   
  </script>
客户端上传文件时,用Javascript(Js)取得文件名及文件后缀(File,图片)   
<SCRIPT LANGUAGE="JavaScript">
<!--
function reAsk(sStr)
{
    return confirm(sStr);
}
function getFileName(o)
{
    var pos=o.value.lastIndexOf("\\");
    return o.value.substring(pos+1);//文件名
    
}
function GetFileExt(o)
{
    return o.value.replace(/.+\./,"");
}
//-->
</SCRIPT><input type="file" size=38 name="file1" onchange="alert(getFileName(this)+'\n'+GetFileExt(this));"/>