[color=#993300]图片按钮用onclick调用js判断表单里的值不为空是  调用不到JS 就和没有JS文件一样 但我在其他网页中用的没问题  我是这样的  看代码color]<script>
function check_Reg(ActionName,chkName){
//验证用户注册信息
//var txt_username=trim(document.all("txt_username").value) //用户名
//var txt_userpass=trim(document.all("txt_userpass").value) //密码
var ly_name=trim(document.all("ly_name").value)                //留言人 
var ly_mail=trim(document.all("ly_mail").value)                //E-mail
var ly_message=trim(document.all("ly_message").value)             //消息
/*if (txt_username==""){
alert("Please input the userid!");
document.all("txt_username").select();
return false;
}*/

if (ly_name==""){
alert("Please input your name!");
document.all("ly_name").select();
return false;
}
if (ly_mail==""){
alert("Please input your e-mail!");
document.all("ly_mail").select();
return false;
}
if(ly_mail!=""){
if(ly_mail.indexOf('@') == -1){
alert("E-mail error!");
document.all("ly_mail").select();
return false;
}
if(ly_mail.indexOf('.') == -1){
alert("E-mail error!");
document.all("ly_mail").select();
return false;
}
}
if (ly_message==""){
alert("Please input message!");
document.all("ly_message").select();
return false;
}
document.frmName.action="admin/ly_update_save.asp";
//document.frmName.submit()
}
</script><form method="post" id="contactform" name="frmName">
<ol>
              <li>
                <label for="ly_name">Your Name <span class="red">*</span></label>
                <input id="ly_name" name="ly_name" class="text" />
              </li>
              <li>
                <label for="ly_mail">Your email <span class="red">*</span></label>
                <input id="ly_mail" name="ly_mail" class="text" />
              </li>
              <li>
                <label for="ly_company">Your Organization</label>
                <input id="ly_company" name="ly_company" class="text" />
                <label for="ly_message">Message <span class="red">*</span></label>
                <textarea id="ly_message" name="ly_message" rows="6" cols="50"></textarea>
              </li>
              <li class="buttons">
                 <input name="submit" style="border:0px" type="image" onclick="check_Reg()" src="images/send.gif"/>
                <input name="update_id" type="hidden" id="update_id" value="2" />
              </li>
          </ol>
      </form>

解决方案 »

  1.   

    check_Reg是有参数的!你调用时有写参数么?
      

  2.   

    <input type="image" /> 它跟 <input type="submit" /> 的行为是一样的,都是点击的时候把form的数据提交。不同的是它显示一张图,仅此而已所以你要验证的话,还是通过<form onsubmit="return check_Reg()"> 这样的形式来验证吧
      

  3.   

    trim 这个函数你是在哪定义的?
      

  4.   

    能不能说的详细点啊 还有TRIM函数不是自带的嘛  还需要自己定义?check_Reg()可以不带参数啊  我在其它页面完全好用。
      

  5.   

    同意 3 楼的说法,应该使用比较规范用法。还可以把 document.all("ly_name").value 改为 document.getElementById(element); 试试。还有可试着把 JavaScript 脚本放到 Html 代码的未尾处。 听说 JavaScript 放到前面对于 IE 有时会有总问题。 还有也会使网页的加载变慢。
      

  6.   

    JavaScript 是没有 trim() 函数的.
    function trim(str){
    return str.replace(/^\s+|\s+$/g, '');
    }function trimStart(str){
    return str.replace(/^\s+/, '');
    }function trimEnd(str){
    return str.replace(/\s+$/, '');
    }
      

  7.   

    javascript 没有trim 函数,你在别的页面好用估计是在那个页面中定义了trim函数,你查一查其它页面中是否引用了包含 trim函数的JS文件。
      

  8.   

    check_Reg()  你定义的有2个参数   你调用的时候不传参数   这会不出问题?不可能的
    而且  你这样写表单验证也不怎么好   看起来麻烦了
      

  9.   

    不懂不要乱讲,JS根本没有trim函数,你在哪看见的?
      

  10.   

    上面的引错了,不好意思!
    不懂不要乱讲,JS根本没有trim函数,你在哪看见的?
      

  11.   

    是的 我在别的页面引用了  定义了TRIM 所以问题出在我的表单有重名  哎  当时在一个包含的页面有同名的表单  换个名字就好了