标签:ntb mamicode get document rip man 事件 点击 aaa
表单:form
DOM树
表单的目的:提交信息
获得要提交的信息
```html
```
提交表单。md5加密密码,表单优化
<!--
表单绑定提交事件
onsubmit = 绑定一个提交检测的函数,true/false
将这个结果返回给表单,使用onsubmit接受!
onsubmit = 'return aaa()'
-->
<form action="https://www.baidu.com/" method="post" onsubmit="return aaa()">
<p>
<span>用户名:</span><input type="text" id="username" name="username">
</p>
<p>
<span>密码:</span><input type="password" id="input_password">
</p>
<input type="hidden" id="md5_password" name="password">
<!--绑定事件 onclick 被点击-->
<button type="submit">提交</button>
</form>
<script>
function aaa() {
alert(1);
var uname = document.getElementById('input_password');
var pwd = document.getElementById('input_password');
var md5pwd = document.getElementById('md5_password');
md5pwd.value =md5(pwd.value);//在<head>中添加<script src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.min.js"></script>
// 可以校验判断表单内容,true就是通过提交,false阻止提交
return true;
}
</script>
标签:ntb mamicode get document rip man 事件 点击 aaa
原文地址:https://www.cnblogs.com/lmx-181028/p/12285929.html