0

heyy... i need to print a form and validate data . for both actions i need only one submit button. i did like this.

<input name="btnSubmit" type="submit"  onclick="return validate(); window.print() "  value="Print Bill" />

bt it is not working.. please can some one give me a help..

Edited by Kadafiz: n/a

2
Contributors
1
Reply
8
Views
6 Years
Discussion Span
Last Post by saideepthi.bits
0

heyy... i need to print a form and validate data . for both actions i need only one submit button. i did like this.

<input name="btnSubmit" type="submit"  onclick="return validate(); window.print() "  value="Print Bill" />

bt it is not working.. please can some one give me a help..

There is only one onSubmit event handler per form. But it can do more than one thing:

<form onSubmit="action1;action2;action3">

If you want the onSubmit event handler to invoke a funtion to validate form data, then ensure that the function returns true (valid data) or false (invalid data) and then return the result in the onSubmit handler:

<form onsubmit="return function1()">

To invoke two funtions and combine the results ue:

<form onSubmit=" return (function1() && funtion2())">

When you hit a submit button the onSubmit event handler invoked.

You can also submit a form using JavaScript, e.g.:

<form name="myForm" onSubmit="function1()">
</form>

<script language="JavaScript"><!--
document.myForm.submit();
//--></script>

However, the onSubmit event handler will NOT not invoked, but you can always invoke it yourself:

<script language="JavaScript"><!--
if (function1())
document.myForm.submit();
//--></script>

Likewise, you could invoke two functions to validate your form:

<script language="JavaScript"><!--
if (function1() && function2())
document.myForm.submit();
//--></script>

Note, that in the last example, if function1() returns false function2() will not be invoked.

To add this to your own "submit" button use:

<form name="myForm">
<imput type="button" value="Submit" onClick="if (function1() && function2()) document.myForm.submit();">
</form>

Edited by saideepthi.bits: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.