We help IT Professionals succeed at work.

javascript form submition

BR
BR asked
on
116 Views
Last Modified: 2017-04-06
Dear Experts,
I use a javascript to ask the user 'Are you sure?' before they submit the form

Below code works fine when my user clicks the submit button. But I want it to work just before the form is submitted. ( not onclick )

How can I do that? ( I know that I should use it on the <form tag like onSubmit  but I couldn't manage it)

<input type="submit" name="submit" id="submit" value="Submit" onclick="clicked(event)">

<script>
function clicked(e)
{
    if(!confirm('Are you Sure?'))e.preventDefault();
}
</script>

Open in new window

Comment
Watch Question

Software Tead Lead / Business Analyst / System Analyst / Data Engineer / Applications Consultant
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
BRDigital Marketing

Author

Commented:
thank you
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.