473,326 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Form onsubmit is not working ..!!!!

dmjpro
2,476 2GB
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Untitled Document</title>
  6. <script type="text/javascript">
  7. function validate(){
  8.     alert('Yahoo...!!!');
  9.     return false;
  10. }
  11. </script>
  12. </head>
  13.  
  14. <body>
  15. <form onSubmit="return validate()">
  16. <input type=button value=submit onclick="this.form.submit()"/>
  17. </form>
  18. </body>
  19. </html>
  20.  

The function validate is not working ..!!!!!!!
Sep 11 '08 #1
6 13055
acoder
16,027 Expert Mod 8TB
onsubmit occurs when a submit button is clicked. That's just a normal button.
Sep 11 '08 #2
Dormilich
8,658 Expert Mod 8TB
a further note: "onsubmit" and "onSubmit" is not the same in XHTML. for events it is best to use only lower case attributes. (and IE can't properly handle XHTML)
Sep 11 '08 #3
Ferris
101 100+
you can use HTML submit element to post the form.

change
Expand|Select|Wrap|Line Numbers
  1. <input type=button value=submit onclick="this.form.submit()" />
into
Expand|Select|Wrap|Line Numbers
  1. <input type="submit" value="submit" />
Sep 12 '08 #4
dmjpro
2,476 2GB
onsubmit occurs when a submit button is clicked. That's just a normal button.
But Acoder i am submitting the form then why it shouldn't work ?
Sep 12 '08 #5
Ferris
101 100+
The submit method does not invoke the onsubmit event handler. Call the onsubmit event handler directly.

Expand|Select|Wrap|Line Numbers
  1.       <form onSubmit="return validate();">
  2.       <input type=button value=submit onclick="this.form.onsubmit();"/>
  3.       </form>
  4.  
Sep 12 '08 #6
acoder
16,027 Expert Mod 8TB
But Acoder i am submitting the form then why it shouldn't work ?
I'll repeat what I said again highlighting the important points:

onsubmit occurs when a submit button is clicked. That's just a normal button. Calling the submit() method is not the same as clicking the submit button.
Sep 12 '08 #7

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.