名称属性抑制onClick功能
下面的代码正常工作,它更改了密码类型,以显示输入为文本。 将名称属性添加到“密码”以从PHP中的$ post检索数据时,会出现ProLEM。我认为可能没有一种方法可以在没有“名称”的情况下获取数据的数据,但是我的reasearch表明,没有“名称”属性,无法检索数据。
问题:如何带入名称属性并保持我的功能?
<div>
<label for="password">Passwort (8 min. pls. )</label>
<input type="password" id="password" minlenght="8" required>
</div>
<div>
<label for="anzeigen">Passwort anzeigen</label>
<input type="checkbox" onclick="anzeigen()" >
</div>
<div>
<input type="submit" id="mitmachen" value="mitmachen">
</div>
</form>
<script>
function anzeigen() {
var x = document.getElementById("password");
if (x.type === "password") {
x.type = "text";
}else {
x.type = "password";
}
}
</script>
The code below works fine, it changes the type of password to reveal the input as text.
The prolem appears when adding a name attribut to "password" in order to retrieve data from $POST in php. I thought there might be a way to get the data on serverside without a "name", but my reasearch showed that without a "name" attribute no data can be retrieved.
Question: How to bring in the name attribute and keep my functionality?
<div>
<label for="password">Passwort (8 min. pls. )</label>
<input type="password" id="password" minlenght="8" required>
</div>
<div>
<label for="anzeigen">Passwort anzeigen</label>
<input type="checkbox" onclick="anzeigen()" >
</div>
<div>
<input type="submit" id="mitmachen" value="mitmachen">
</div>
</form>
<script>
function anzeigen() {
var x = document.getElementById("password");
if (x.type === "password") {
x.type = "text";
}else {
x.type = "password";
}
}
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论