# Javascript onsubmit form confirm



## scrubbicus (Jan 23, 2009)

I'm trying to write some quick javascript so when someone submits a form it asks them if they want to submit it or not. I got the confirm coming up but if they press cancel it still submits.

I'm trying:

function test()
{
answer = confirm("Are you sure?");

if(answer)
{

}
else
{
return false;
}
}


----------



## Shadow2531 (Apr 30, 2001)

onsubmit="return confirm('Are you sure?');" works for me.


----------

