SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2008
    Posts
    155
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    confirm() submit

    Hey I have a form that I want a confirm box to pop up on prior to submit. This is my code:

    Code:
    	<script type="text/javascript">
    	function confirmation() {
    		var answer = confirm("Are you sure?")
    		if(answer){
    			return true;
    		}else{
    			return false;
    		}
    	}
    	</script>
    
    <input type="submit" name="submit" value="Submit" onClick="confirmation();">
    I would like it so that the form does not submit if the user selects cancel. Can anyone explain why this is not working? Thanks!

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:

    Code html4strict:
    <input type="submit" name="submit" value="Submit" onClick="return confirmation()">
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2008
    Posts
    155
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow that was dumb of me to forget that. Thanks!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •