 | 
September 11th, 2008, 06:23 PM
|  | Lives Here | | Join Date: Jan 2007 Location: India (West-Bengal) Age: 25
Posts: 2,164
| | Form onsubmit is not working ..!!!! -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
-
<title>Untitled Document</title>
-
<script type="text/javascript">
-
function validate(){
-
alert('Yahoo...!!!');
-
return false;
-
}
-
</script>
-
</head>
-
-
<body>
-
<form onSubmit="return validate()">
-
<input type=button value=submit onclick="this.form.submit()"/>
-
</form>
-
</body>
-
</html>
-
The function validate is not working ..!!!!!!!
| 
September 11th, 2008, 06:53 PM
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 12,964
| |
onsubmit occurs when a submit button is clicked. That's just a normal button.
| 
September 11th, 2008, 07:49 PM
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany Age: 31
Posts: 894
| |
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)
| 
September 12th, 2008, 05:43 AM
|  | Member | | Join Date: Oct 2007 Location: Shanghai Age: 22
Posts: 102
| |
you can use HTML submit element to post the form.
change - <input type=button value=submit onclick="this.form.submit()" />
into - <input type="submit" value="submit" />
| 
September 12th, 2008, 06:31 AM
|  | Lives Here | | Join Date: Jan 2007 Location: India (West-Bengal) Age: 25
Posts: 2,164
| | Quote: |
Originally Posted by acoder 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 ?
| 
September 12th, 2008, 06:54 AM
|  | Member | | Join Date: Oct 2007 Location: Shanghai Age: 22
Posts: 102
| |
The submit method does not invoke the onsubmit event handler. Call the onsubmit event handler directly. -
<form onSubmit="return validate();">
-
<input type=button value=submit onclick="this.form.onsubmit();"/>
-
</form>
-
| 
September 12th, 2008, 12:17 PM
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 12,964
| | Quote: |
Originally Posted by dmjpro 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.
|  | | Thread Tools | Search this Thread | | | |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 205,248 network members.
|