[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>
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>
function trim(str){
return str.replace(/^\s+|\s+$/g, '');
}function trimStart(str){
return str.replace(/^\s+/, '');
}function trimEnd(str){
return str.replace(/\s+$/, '');
}
而且 你这样写表单验证也不怎么好 看起来麻烦了
不懂不要乱讲,JS根本没有trim函数,你在哪看见的?