Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
162 views
in Technique[技术] by (71.8m points)

html - Why does validateForm display the whole table instead of the row (using JavaScript)?

I am trying to display email address and password for every employee by submitting their id, I used this code

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function validateForm() {
  var x = document.forms["myMail"]["rowId"].value;
  if (x == "") {
    alert("Please type a valid National ID");
    return false;
  }
}
</script>
</head>
<body>

<form name="myMail" action="teamId.html" onsubmit="return validateForm()" method="post">
  National ID : <input type="number" name="rowId" required>
  <input type="submit" value="Get my Mail">
</form>

</body>
</html>

but when submitting it displays the whole table not the row that contains the employee info

and this is the first row of the table

<td height=53 class=xl6455 width=64 style='height:39.95pt;width:48pt'>id</td>
  <td class=xl6455 width=191 style='border-left:none;width:143pt'>National I.D</td>
  <td class=xl6555 width=390 style='border-left:none;width:293pt'>Name</td>
  <td class=xl6555 width=242 style='border-left:none;width:182pt'>E-mail
  Address</td>
  <td class=xl6555 width=221 style='border-left:none;width:166pt'>First time
  only Password</td>
  <td class=xl6555 width=200 style='border-left:none;width:150pt'>Level</td>
 </tr>
 <tr height=53 style='mso-height-source:userset;height:39.95pt'>
  <td height=53 class=xl6455 style='height:39.95pt;border-top:none'>1</td>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...