hi guys i want to put a alert message on submit button when i click on that it ask that "Are you sure you want to submit" if i click yes the form should submit if no that it do no thing
kindly help me in this regards waiting for your replies
alert message on submit
Moderator: General Moderators
Re: alert message on submit
document.getElementById("form").onsubmit=function(){
if(!confirm("Are you sure you want to submit?"))
return false;
return true;
}
if(!confirm("Are you sure you want to submit?"))
return false;
return true;
}
Re: alert message on submit
you have to use js, do following stuff to get your answer::
call a function in submit button like:::
after that write below js code in head section::
that sit
call a function in submit button like:::
Code: Select all
<input type="submit" name"Submit" Value="Submit" onclick="return form_action()">Code: Select all
<script type="text/javascript">
function form_action()
{
if(alert("You really want to submit form"))
return true;
else
return false;
}
</script>
Re: alert message on submit
An alert() does not give you any options. It's not for giving the user an option. And I wouldn't use an onclick handler for the submit button, I'd use instead the "onsubmit" event for the form itself.dheeraj wrote:you have to use js, do following stuff to get your answer::
call a function in submit button like:::after that write below js code in head section::Code: Select all
<input type="submit" name"Submit" Value="Submit" onclick="return form_action()">that sitCode: Select all
<script type="text/javascript"> function form_action() { if(alert("You really want to submit form")) return true; else return false; } </script>
For example:
Code: Select all
<html>
<head>
<title>Test</title>
<script type="text/javascript">
function ConfirmSubmit()
{
return confirm("Are you sure you want to submit this form?"); // could convert to if/else
}
</script>
</head>
<body>
<form action="handler.php" method="post" onsubmit="return ConfirmSubmit();">
Name: <input type="text" name="name" /><br />
Age: <input type="text" name="age" /><br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
Re: alert message on submit
thanks to all of u i have done this with your help
thanks
thanks