首页 javaWEB 表格提交前的验证(转)

表格提交前的验证(转)

就在在表单提交以前验正了表单里的内容 两个文本内容,一个用户一个密码 一个提交 在提交时检测表单里的内容,如果符合就转向…

就在在表单提交以前验正了表单里的内容

两个文本内容,一个用户一个密码

一个提交

在提交时检测表单里的内容,如果符合就转向另一个网页

 

 

正确用户名字yq1012

正确用户密码   yq1012

 

 

login.html代码

<html>
<head>
<title>登陆</title>
</head>
<script language="javascript">
function check()
{
 if (document.form1.username.value=="")
 {
  document.getElementById("usernameTip").innerHTML="<font color=red>请输入用户名</font>";
  document.form1.username.focus();
  return false;
 }
 else
  document.getElementById("usernameTip").innerHTML="";
 if (document.form1.userpwd.value=="")
 {
  document.getElementById("userpwdTip").innerHTML="<font color=red>请输入密码</font>";
  document.form1.userpwd.focus();
  return false;
 }
 else
  document.getElementById("userpwdTip").innerHTML="";
 if (document.form1.username.value!="yq1012")//============用户名:admin =========
 {
  document.getElementById("ischeckTip").innerHTML="<font color=red>用户名不存在</font>";
  document.form1.username.focus();
     return false;
 }
 if (document.form1.userpwd.value!="yq1012")//=======密码:123 =====
 {
  document.getElementById("ischeckTip").innerHTML="<font color=red>密码错误</font>";
  document.form1.userpwd.focus();
     return false;
 }
   return true;

}</script>
<body>
<form name="form1"  method="post" action="index.html">
  <table width="348" align="center" cellpadding="1" cellspacing="1" bgcolor="#99CCFF">
    <tr>
      <td width="59" bgcolor="#FFFFFF">用户名:</td>
      <td width="105" bgcolor="#FFFFFF"><input name="username" type="text" size="15" bgcolor="#FFFFFF"></td>
      <td width="174" id="usernameTip" bgcolor="#FFFFFF"> </td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF">密  码:</td>
      <td bgcolor="#FFFFFF"><input name="userpwd" type="password" size="15" bgcolor="#FFFFFF"></td>
      <td id="userpwdTip" bgcolor="#FFFFFF"> </td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF"> </td>
      <td bgcolor="#FFFFFF"><input type="submit" name="Submit1" value="提交" onClick="return check()">
      <input type="reset" name="Submit2" value="重置"></td>
      <td id="ischeckTip" bgcolor="#FFFFFF"> </td>
    </tr>
  </table>
</form>
</body>
</html>

 

 

index.html代码

<html>
<head>
<title>欢迎</title>
</head>
<body>
登陆成功
</body>
</html>

 

免责声明:文章内容不代表本站立场,本站不对其内容的真实性、完整性、准确性给予任何担保、暗示和承诺,仅供读者参考,文章版权归原作者所有。如本文内容影响到您的合法权益(内容、图片等),请及时联系本站,我们会及时删除处理。

为您推荐

nodejs 整理记录

nodejs 整理记录

下载包 https://blog.csdn.net/m0_59878114/article/details/120274...
websocket测试html

websocket测试html

<!DOCTYPE html> <html> <head> <meta cha...
bigdemical两个数比较大小

bigdemical两个数比较大小

/*int result = bigdemical1.compareTo(bigdemical2) result = -...
Beetl2.7 中文文档

Beetl2.7 中文文档

Beetl目前版本是2.7.23,相对于其他java模板引擎,具有功能齐全,语法直观,性能超高,以及编写的模板容易维护等...
纯CSS实现多个便签在一行展示,拖动滚动

纯CSS实现多个便签在一行展示,拖动滚动

div <h2>请注意需要在移动端预览,PC端拖拽无效果</h2> <div class=...
返回顶部