Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1124
  • Last Modified:

SIMPLE YES/NO ALERT - URGENT

HI Experts,

Need a really quick answer to the following:

I need an alert box to pop up when a form is submitted with "are you sure you want to do this?" as the message and a choice of "yes" or "no" to be presented in the form of 2 buttons. If "yes" is clicked then the form is submitted, if "no" is clicked then the form is not submitted.


Thanks,



PJORDANNA

0
pjordanna
Asked:
pjordanna
1 Solution
 
sajuksCommented:
<HEAD>



<SCRIPT LANGUAGE="JavaScript">
function getInfo() {
doyou = confirm("Do you want to continue? (OK = Yes   Cancel = No)");

if (doyou == true)
{

return true
}
else
{

return false
}
}
</script>
<BODY>

<form method="POST"  onSubmit ="return getInfo()">
<input type="text">
  <input type="submit" value="Submit" name="B1">
  <input type="reset" value="Reset" name="B2"></p>
</form>



</BODY>
0
 
gam3r_3xtr3m3Commented:
try:

<form onSubmit="return confirm('Are you sure you want to do this?')">
<input type="submit" />
</form>
0
 
James RodgersWeb Applications DeveloperCommented:
or this,
this will call a form validation routine called validateForm() and if the data is valid will then prompt the user to confirm
<script>
function validateForm(objForm){
// data validation goes here
return true;
}

</script>
<form name="myForm" action="" method="" onSubmit="if(validateForm(this)){ return confirm('Are you sure you want to do this?\nClick Ok to continue or Cancel to stop.')} else { return false}">

<input type="submit" value="Submit">
</form>
0
 
pjordannaAuthor Commented:
OK that's got it.



PJORDANNA
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now