最近,我创建了一个网页,让我了解更多关于HTML的信息,并找到了'required'属性。我把它加到地里,但它什么也没做。
有人能告诉我我对“必需的”属性的错误吗?
当字段为空时,我希望它写上“请填写此字段”。
<html>
<head>
<link href="icon.ico" rel="icon">
<title>Log In</title>
</head>
<body>
<h1 align="center">Welcome to site</h1>
<hr width="50%"/>
<br/>
<table align="center">
<form>
<tr>
<td>Log In : </td>
<td><input type="text" name="LogInEmail" placeholder="Enter your email" required></td> </tr><tr>
<td>Password : </td>
<td><input type="password" name="password" placeholder="Password" required></td>
</tr>
</form>
</table>
<br/>
<table align="center">
<form>
<tr>
<td><input type="submit" value=" Log In "/></td>
</tr>
</form>
</table>
</body>
</html>发布于 2016-11-20 09:12:27
请确保你已在第一份表格内提交。你有多种表格。因此所需的是不起作用的。
<html>
<head>
<link href="icon.ico" rel="icon">
<title>Log In</title>
</head>
<body>
<h1 align="center">Welcome to site</h1>
<hr width="50%" />
<br/>
<table align="center">
<form id="form1" runat="server">
<tr>
<td>Log In : </td>
<td>
<input type="text" name="LogInEmail" placeholder="Enter your email" required>
</td>
</tr>
<tr>
<td>Password : </td>
<td>
<input type="password" name="password" placeholder="Password" required>
</td>
</tr>
<tr>
<td>
<input type="submit" value=" Log In " />
</td>
</tr>
</form>
</table>
</body>
</html>但是,如果您坚持要有多个表和表单,那么在提交之前,可以验证第一个表单。如果我没有错,您正在尝试一个更好的UI位置,它可以处理CSS而不是多个表单和表。
发布于 2016-11-20 10:32:54
您接受了两个form.You,应该将提交按钮放置在相同的表单中,输入要求字段exist.Be小心使用表单。
https://stackoverflow.com/questions/40702308
复制相似问题