Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Sep 2004
    Posts
    43
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Form onSubmit alert()

    I have a form that onSubmit processes using "formMail". I would like to also have it display an "alert('Form Submitted - Thank You") onSubmit as well. I have tried all kinds of methods, but nothing is working. Any suggestions? Thanks!

    Link: http://www.crosst.org/saved.html
    Last edited by svoltmer; 08-12-2008 at 06:02 PM. Reason: added link

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    At the end of whatever validation you have:-

    alert ("Form submitted - Thank you!");
    return true;
    }

    Note the position of the quotation marks. And both must be either single or double quotes, but not one of each.


    Edit: Your form appears to have no validation at present. Change this line to:-

    <input name="submit" type="submit" class="submit" id="submit" value="Submit" onclick = "return showMessage()" />

    <script type = "text/javascript">
    function showMessage() {
    alert ("Form submitted - Thank you!");
    return true;
    }
    </script>

    Also note that in Internet Explorer, names and IDs are global variables and thus you should NEVER use a global variable or function name which is the same as an element name or ID. You should also avoid giving names to your variables/functions/arguments words which are JavaScript methods/attributes such as 'name' or 'id' or 'value' or 'checked' or 'submit' or 'replace' or 'parseInt'.






    Quizmaster: Which surname was shared by a historical outlaw called "Butch" and a fictional cowboy called "Hopalong"?
    Contestant: Lesbian.
    Last edited by Philip M; 08-12-2008 at 06:51 PM.

  • #3
    New Coder
    Join Date
    Sep 2004
    Posts
    43
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thanks!

    That was it. I don't know why I didn't have any action on the input for the submit. I appreciate your help. Have a blessed day!


  •  

    Posting Permissions

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