java模拟登录网页 From表单中有onsubmint属性 阻止了自动提交
怎样处理这个onsubmint 使程序能自动登录,
<form name="login" action="redirct_index.htm" method="post" onsubmit="return formSubmit2(this);">
function formSubmit2()
{
var oUserName = document.getElementById("userName");
var oPassword = document.getElementById("password");
if (1 == vldcode_en)
{
var oVldcode = document.getElementById("vldcode");
}
if (0 == oUserName.value.length)
{
document.getElementById("messages").innerHTML="请输入用户名!";
oUserName.focus();
return false;
}
/*
if (0 == oPassword.value.length)
{
document.getElementById("messages").innerHTML="请输入密码!";
oPassword.focus();
return false;
}
*/
if(!checkStringChar(oPassword,' '))
{
document.getElementById("messages").innerHTML="密码不能包含空格!";
oPassword.focus();
return false;
}
oUserName.value = trim(oUserName.value);
//oPassword.value = trim(oPassword.value);
if (1 == vldcode_en)
{
oVldcode.value = trim(oVldcode.value);
if ( oVldcode.value == "" )
{
document.getElementById("messages").innerHTML="请输入验证码!";
if (1 == mapOvertime)
{
get_vldbmp();
}
else
{
oVldcode.focus();
}
return false;
}
else if (1 == mapOvertime)
{
document.getElementById("messages").innerHTML="验证码已超时,请重新输入!";
get_vldbmp();
return false;
}
else if (!/(^[a-zA-Z0-9]{4}$)/.test(oVldcode.value))
{
document.getElementById("messages").innerHTML="验证码错误!";
return false;
}
}
set_cookie("userName", escape(oUserName.value), null, "/");
set_cookie("password", oPassword.value, null, "/");
if (1 == vldcode_en)
{
set_cookie("vldcode", oVldcode.value, null, "/");
}
var d = new Date;
document.login.rtime.value = (d.getTime() / 500);
return true;
}
var copyright_time="2008-2013";
var deviceName = "H3C S1626";
var messages = "";
var vldcode_en = 0;
[解决办法]
直接放在网页加载事件里面不可以吗?
[解决办法]