promotion image of download ymail app
Promoted

按鈕按下後出現彈跳訊息的語法(javascript

<form action="http://tw.yahoo.com">

請提出您的意見<br>

<textarea style='height:100px; width=300px'>

</textarea>

<br>

<input type=submit value='傳送'>

</form>

只要一點按扭「傳送」,我要網頁立刻出現一個警告框框

「確定」及「取消」二個按鈕

確定才會到指定的網頁,取消當然就是沒事

1 Answer

Rating
  • 1 decade ago
    Favorite Answer

    通常送出表單前會檢查有沒有填入資料,你如果不要檢查,就將紅色的刪除。

    <html>

    <script language='javascript'>

    function validate()

    {

    if ( !document.forms[0].elements[0].value )

    { alert("你未填入意見")

    return false

    }

    return confirm('你確定要送出?')

    }

    </script>

    <body>

    <form action="http://tw.yahoo.com" onSubmit="return validate()">

    請提出您的意見<br>

    <textarea style='height:100px; width=300px'>

    </textarea>

    <br>

    <input type=submit value='傳送'>

    </form>

    </body>

    </html>

    • Commenter avatarLogin to reply the answers
Still have questions? Get your answers by asking now.