<td class="tilte">
<input type="image" name="onsubmit" src="images/img/logn_l.gif" onclick="return onsubmit()" alt="登录" width="45" height="22" border="0">
<input type="image" name="clear" src="images/img/logn_c.gif" onclick="return onReset()" alt="清空" width="45" height="22" border="0">
</td>
js函数:<script language="JavaScript" type="text/JavaScript">
<!--
function onsubmit()
{
alert("-----跳转-------");
var un="<%=request.getAttribute("un")%>";
alert("un="+un);
if(isBlank(document.forms[0].userName.value))
{
alert("对不起,管理员名称不能为空!");
document.forms[0].userName.focus();
return false;
}
else if(isBlank(document.forms[0].userPass.value))
{
alert("请输入您的密码!");
document.forms[0].userPass.focus();
return false;
}
if(un="" || un=null){
document.forms[1].un.value=document.forms[0].userName.value;
document.forms[1].pw.value=document.forms[0].userPass.value;
document.forms[1].submit();
}
else{
document.forms[0].submit();
}
return true;
}
function onReset()
{
document.forms[0].userName.value="";
document.forms[0].userPass.value="";
return false;
}
function isBlank(s)
{
for(var i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if ((c != ' ') && (c != '\n') && (c != '\t'))
return false;
}
return true;
}
//-->
</script>红色部分尝试了: onclick="onsubmit()"或者 onclick="onsubmit();return false;"均不能完成跳到js代码部分执行js函数,而 onclick="alert("print")"是可以输出的,请达人多指点!!小问题挺折腾人的,谢谢!!
<input type="image" name="onsubmit" src="images/img/logn_l.gif" onclick="return onsubmit()" alt="登录" width="45" height="22" border="0">
<input type="image" name="clear" src="images/img/logn_c.gif" onclick="return onReset()" alt="清空" width="45" height="22" border="0">
</td>
js函数:<script language="JavaScript" type="text/JavaScript">
<!--
function onsubmit()
{
alert("-----跳转-------");
var un="<%=request.getAttribute("un")%>";
alert("un="+un);
if(isBlank(document.forms[0].userName.value))
{
alert("对不起,管理员名称不能为空!");
document.forms[0].userName.focus();
return false;
}
else if(isBlank(document.forms[0].userPass.value))
{
alert("请输入您的密码!");
document.forms[0].userPass.focus();
return false;
}
if(un="" || un=null){
document.forms[1].un.value=document.forms[0].userName.value;
document.forms[1].pw.value=document.forms[0].userPass.value;
document.forms[1].submit();
}
else{
document.forms[0].submit();
}
return true;
}
function onReset()
{
document.forms[0].userName.value="";
document.forms[0].userPass.value="";
return false;
}
function isBlank(s)
{
for(var i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if ((c != ' ') && (c != '\n') && (c != '\t'))
return false;
}
return true;
}
//-->
</script>红色部分尝试了: onclick="onsubmit()"或者 onclick="onsubmit();return false;"均不能完成跳到js代码部分执行js函数,而 onclick="alert("print")"是可以输出的,请达人多指点!!小问题挺折腾人的,谢谢!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货