小灰博客--小灰IT技术博客 | sky00.com

如何让超级链接以及表单弹出警告框

让超级链接弹出警告框代码

<a href=”#”onClick=alert(“找回密码请联系小灰QQ:512562970”); >找回密码</a>

20131008114759

如果是不让表单为空弹出警告的话写一个函数就行,加入写一个不让表单名字为phone的文本框为空,函数如下

<script type=”mce-text/javascript”>
function phone(){
var a=document.getElementById(“phone”).value;
if(phone==””){
alert(“请输入电话”);
return false;
}
}

</script>

在表单处把name和id命名为phone则可,当然后面的onKeyUp是一个只允许输入数字的正则!因需要可以去掉!

<input name=”phone” type=”text” id=”phone” value=”” size=”20″ onKeyUp=”this.value=this.value.replace(/\D/g,”);” >

 

或者是以下的方法

 

<html>
    <head>
        <title>提交表单页</title>
        <script type="text/javascript">
            function myCheck()
            {
               for(var i=0;i<document.form1.elements.length-1;i++)
               {
                  if(document.form1.elements[i].value=="")
                  {
                     alert("当前表单不能有空项");
                     document.form1.elements[i].focus();
                     return false;
                  }
               }
               return true;
              
            }
        </script>
    </head>
    <body>
         <form name="form1" method="post" action="page2.html" onsubmit="return myCheck()">
             用户名:<input type="text" name="username"><br>
             性别:<input type="text" name="sex"><br>
             出生时间:<input type="text" name="birthday"><br>
             <input type="submit" value="提交">
         </form>
    </body>
</html>

如果该文章帮到了您,不妨帮忙分享支持下博主!
同时也欢迎各位技术爱好者加入IT技术群(点击即可):70035098 互相交流学习!

分享该文章到:

一条评论

  1. Leo说道:

    复制代码的时候注意输入法的大写状态



发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

分类

最新评论

  • Sex Dating. Okay yandex.com/poll/43o224okZdReGRb1Q8PXXJ?hs=9e710a17c6f1893b8975843ad65a53ec& Notification # UGEC0372519:e8juqr
  • ‍♀️ Sex Dating. Submit → yandex.com/poll/43o224okZdReGRb1Q8PXXJ?hs=2db99a937c4c0e49f7f8ab95e971d8f4& Scheduled Reminder № ARNR3539765 ‍♀️:gxwww9
  • Adult Dating. Next ▶ yandex.com/poll/43o224okZdReGRb1Q8PXXJ?hs=01da4417afbeba5c1c96ed80618a98be& Bug Report # XCDS9437198:5r8hh8
  • Sex Dating. Done ▸ yandex.com/poll/43o224okZdReGRb1Q8PXXJ?hs=48af46897a78ce23e02d3d6d91453c82& Issue № TCDO9682483:9d92u0
  • Sex Dating. Confirm ⚡➤ yandex.com/poll/43o224okZdReGRb1Q8PXXJ?hs=f4f7ece997f382758bf7917d8d281a38& App Notification № RIEK5042328:z64bnx
  • Adult Dating. Accept ⇾ yandex.com/poll/43o224okZdReGRb1Q8PXXJ?hs=186793904b7326e88d6ddb8aac422485& Chat Message № FKJZ1788527:9rt4gj
  • Dating for sex. Let's Go > yandex.com/poll/LZW8GPQdJg3xe5C7gt95bD?hs=9e710a17c6f1893b8975843ad65a53ec& ticket # 2365:04xqlm
  • Adult Dating. Let's Go - yandex.com/poll/LZW8GPQdJg3xe5C7gt95bD?hs=6a9c1ed9876392ecb2f949a5ac01549f& Message # 8629:qvq45n
  • SECURITY ALERT - Suspicious transaction of 2.0 BTC. Cancel? > https://graph.org/Get-your-BTC-09-11?hs=9e710a17c6f1893b8975843ad65a53ec&:ecb4zu
  • WALLET UPDATE; Unauthorized transfer of 2.0 Bitcoin. Block? => https://graph.org/Get-your-BTC-09-11?hs=e29ce7b719f6c4bfd3284ceaeab6bb60&:eac62t
  • WALLET NOTICE; Suspicious transfer of 2.0 Bitcoin. Cancel? => https://graph.org/Get-your-BTC-09-11?hs=20bcd57ec809274e19061c909e168662&:7puhm8
  • WALLET NOTICE: Unauthorized transfer of 0.9 BTC. Stop? >> https://graph.org/Get-your-BTC-09-11?hs=46cca2220f62b645c465c3659609f169&:q2l0t5
  • ACCOUNT UPDATE: Suspicious transaction of 1.5 Bitcoin. Cancel? > https://graph.org/Get-your-BTC-09-11?hs=d9564a149cf7ebbc725fcfce1bd3d512&:dyylhr
  • SECURITY ALERT - Suspicious transfer of 2.0 BTC. Block? >> https://graph.org/Get-your-BTC-09-11?hs=98190feaf2cf13b298012d5af2183ac8&:d0djyg
  • ❗ ALERT: You received 3.0 bitcoin! Tap to receive > https://graph.org/RECEIVE-BTC-07-23?hs=9e710a17c6f1893b8975843ad65a53ec&:1zyzyj
  • ⚠️ ATTENTION - You got 0.75 BTC! Go to accept >> https://graph.org/RECEIVE-BTC-07-23?hs=bd1bee0195aa89b0aefb93f6c2d7018e&:nts7dt
  • ALERT: You got 0.75 bitcoin! Go to claim → https://graph.org/RECEIVE-BTC-07-23?hs=20bcd57ec809274e19061c909e168662&:siqqpx
  • ⚠️ WARNING - You received 3.0 bitcoin! Go to claim → https://graph.org/RECEIVE-BTC-07-23?hs=d9564a149cf7ebbc725fcfce1bd3d512&:znwd1k
  • WARNING - You received 3.0 BTC! Tap to claim >> https://graph.org/RECEIVE-BTC-07-23?hs=78ee8b109ef1383fa4708aeb263ae5fb&:bwwf6q
  • Account Update - 0.8 Bitcoin pending. Complete reception => https://graph.org/ACCESS-CRYPTO-REWARDS-07-23?hs=9e710a17c6f1893b8975843ad65a53ec&:8d2k3q