這篇文章將為大家詳細(xì)講解有關(guān)JS表單提交信息加密的示例,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
提交表單
<!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><!-- 綁定時(shí)間 onclick被點(diǎn)擊--> <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 綁定一個(gè)提交檢測(cè)函數(shù) true false 將這個(gè)結(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"><!-- 綁定時(shí)間 onclick被點(diǎn)擊--> <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); //可以校驗(yàn)判斷表單內(nèi)容 true 就是通過(guò)提交 false 就是組織提交 return true; }</script></body></html>
關(guān)于“JS表單提交信息加密的示例”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。
新聞名稱(chēng):JS表單提交信息加密的示例-創(chuàng)新互聯(lián)
轉(zhuǎn)載注明:http://sd-ha.com/article36/shppg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站、全網(wǎng)營(yíng)銷(xiāo)推廣、移動(dòng)網(wǎng)站建設(shè)、虛擬主機(jī)、網(wǎng)站策劃、微信公眾號(hào)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容