View Full Version : Alert Yes or No

07-11-2002, 10:17 PM
I am calling the function from a button using onclick. Is it possible to have the alert popup with a yes and no button. The yes lets it continue and no returns false.

Basically what is happening is a user fills in the forms that have no required info, but I want to ask the user if they are really ready to sumbit just incase they hit the enter button instead of the tab button.

<SCRIPT language=JavaScript>
function checkCheckBox(){

alert("Do you want to submit")
if(confirm("")) {
return false;

07-11-2002, 10:24 PM
the following should do you want. be aware, however, that you'll get 'Ok' and 'Cancel' for your buttons, instead of 'Yes' and 'No', and there's no way to change that.

function checkCheckBox(){
return confirm("Do you want to submit");

07-11-2002, 10:28 PM
forget the alert()...

The confirm() gives you OK / Cancel buttons that return true and false respectively.

function confirmAction() {
return confirm ("Are you suuuurrreeee?");

use it in your <form> tag, thus:

<form .... onSubmit="return confirmAction()">

Philip M
07-12-2002, 07:48 PM
Another approach is to disable the enter key:-

function onKeyPress () {
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
if (keycode == 13) {
alert ("Please use the tab key (not the enter key) or click\nwith your mouse to move between the form fields.");
return false
return true
document.onkeypress = onKeyPress;

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum