87,910
社区成员
发帖
与我相关
我的任务
分享
function InputCheck()
{
if (document.form1.num.value == "")
{
alert("用户名不可为空!");
document.form1.num.focus();
return false;
}
if (document.form1.password.value == "")
{
alert("密码不可为空!");
document.form1.password.focus();
return false;
}}
function teacher(){
InputCheck();
document.form1.method= "post";
document.form1.action= "http://QQ.com";
document.form1.submit();
console.log(document.form1.action)
return true;
}
function stu(){
InputCheck();
document.form1.method= "post";
document.form1.action= "http://sina.com ";
document.form1.submit();
return true;
}
<form name="form1" >
<div class="input-wrap">
<input type="text" name="num" placeholder="用户名">
</div>
<div class="input-wrap">
<input type="password" name="password" placeholder="密码">
</div>
</div>
<div class="btns">
<input type="submit" class="current" value='教师' onClick= "teacher()">
<input type="submit" value='学生' onClick= "stu()"> </form>
</div>
<form name="form1">
<div class="input-wrap">
<input type="text" name="num" placeholder="用户名">
</div>
<div class="input-wrap">
<input type="password" name="password" placeholder="密码">
</div>
<div class="btns">
<input type="button" class="current" value='教师' onClick="teacher()">
<input type="button" value='学生' onClick="stu()">
</div>
</form>
function InputCheck() {
if (document.form1.num.value == "") {
alert("用户名不可为空!");
document.form1.num.focus();
return false;
}
if (document.form1.password.value == "") {
alert("密码不可为空!");
document.form1.password.focus();
return false;
}
return true;
}
function teacher() {
if (InputCheck() == true) {
document.form1.method = "post";
document.form1.action = "http://QQ.com";
document.form1.submit();
console.log(document.form1.action)
}
}
function stu() {
if (InputCheck() == true) {
document.form1.method = "post";
document.form1.action = "http://sina.com ";
document.form1.submit();
}
}