I have a form which has 1 textArea and 2 buttons.
Let's call the 1st button "no_empty.htm" because it doesn't approve empty textArea.
Let's call the 2nd button "OK_empty_BUT_alert.htm" because empty textArea is possible but it make the user to check with an alert saying "are you sure that it's empty?"
I like to make it like the following.
If a user clicks the 1st button "no_empty.htm without any text in the textArea.
it says "message, please!." with a confirmation alert.
If a user clicks the 2nd button "OK_empty_BUT_alert.htm" without any text in the textArea.
it says "Are you sure to go to the action page withiout any text in the textAea?" with a yes or no alert.
If the user choose "yes" button, it goes to the action page.
If the user choose "no" button, it just stay there.
If a user clicks the 1st button "no_empty.htm" or the 2nd button with some text in the textArea.
it goes to "no_empty.htm" page without any alert.
The following code doesn't work correctly as I want, but I hope it shows what I want.
Code:<script type = 'text/javascript'> function myAlert(empty) { if (empty['myText'].value.length == 0) { alert('message, please!'); return false } } </script> <script type="text/javascript"> function sure(){ var msg = "Are you sure it's empty?"; return confirm(msg); } </script> <form method='post' action='no_empty.htm' onsubmit="return myAlert(this)"> <textarea name='myText'></textarea> <input type='submit' value="NOempty.htm"> <input type='submit' value='OKemptyBUTalert.htm' onclick="this.form.action='OK_empty_BUT_alert.htm';return sure()"> </form>



Reply With Quote
Bookmarks