這篇文章將為大家詳細講解有關(guān)JS表單提交信息加密的示例,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

提交表單
<!DOCTYPE html><html lang="en"><head>
<meta charset="UTF-8">
<title>Title</title>
<script src="md5.js"></script></head><body><form action="#" method="post" >
<p>
<span>用戶名:</span> <input type="text" id="username" name="username">
</p>
<p>
<span>密碼:</span> <input type="password" id="pwd" name="pwd">
</p><!-- 綁定時間 onclick被點擊-->
<button type="submit" onclick="aaa()" >提交</button></form><script>
function aaa(){
var usern=document.getElementById("username");
var pwd=document.getElementById("pwd");
console.log(usern)
console.log(pwd)
pwd.value=md5(pwd.value);
console.log(pwd.value);
}</script></body></html>優(yōu)化表單提交 md5加密
<!DOCTYPE html><html lang="en"><head>
<meta charset="UTF-8">
<title>Title</title>
<script src="md5.js"></script></head><body><!-- onsubmit 綁定一個提交檢測函數(shù) true false 將這個結(jié)果返回表單 ,使用 onsubmit 接收 onsubmit="return aaa() --><form action="https://home.firefoxchina.cn/" method="post" onsubmit="return aaa()">
<p>
<span>用戶名:</span> <input type="text" id="username" name="username">
</p>
<p>
<span>密碼:</span> <input type="password" id="pwd" name="pwd">
</p>
<input type="hidden" id="md5-password" name="password"><!-- 綁定時間 onclick被點擊-->
<button type="submit" >提交</button></form><script>
function aaa(){
var usern=document.getElementById("username");
var pwd=document.getElementById("pwd");
var md5=document.getElementById("md5-password")
md5.value=md5(pwd.value);
// console.log(usern)
// console.log(pwd)
//pwd.value=md5(pwd.value);
// console.log(pwd.value);
//可以校驗判斷表單內(nèi)容 true 就是通過提交 false 就是組織提交
return true;
}</script></body></html>關(guān)于“JS表單提交信息加密的示例”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
新聞名稱:JS表單提交信息加密的示例-創(chuàng)新互聯(lián)
轉(zhuǎn)載注明:http://chinadenli.net/article36/shppg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站、全網(wǎng)營銷推廣、移動網(wǎng)站建設(shè)、虛擬主機、網(wǎng)站策劃、微信公眾號
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)