...

View Full Version : Running Multiple Functions



Abd
10-28-2003, 02:45 PM
Hi All,

pls I need help on how to run multiple JavaScript, I tried my bellow code, it actually runs(validate) but as soon as I click the Okay button of the Dialog Box it submit the form.

So what I really want is how to use If Construct for testing Functions, see bellow code;

<script language = "Javascript">
function Submittest()
{
Submit();

ValidateForm();

}

</script>

I want to test Submit() [Using IF statement.....] if it returns false, the Script should not allow me to submit the form

Willy Duitt
10-28-2003, 02:55 PM
Uuuuh?


I want to test Submit() [Using IF statement.....] if it returns false, the Script should not allow me to submit the form

The validation script (which you did not post) should
not allow the form to submit() unless the form validates.

Besides, in your Submittest() function.
You are submitting the form and then validating. :confused:

This:

function Submittest()
{
Submit();
ValidateForm();
}
</script>

Should at least be this:

function Submittest()
{
ValidateForm();
Submit();

}
</script>

....Willy

A1ien51
10-28-2003, 03:13 PM
the smarter thing to do would be use the form tag attribute

<form name="theForm" onSubmit="return Validate()">


in your Validate function you would need to return true or false

Abd
10-28-2003, 03:34 PM
Thank guys,

both Submit() and ValidateForm() are JavaScript that validate different textfields.

I just want to be able to run these two different JavaScript together, because I ran one other JavaScript with <form ... tag and am trying to run this Submittest() through the onClick event.

Thanks

liorean
10-28-2003, 04:03 PM
Simply do an inclusive boolean check:

<form ... onsubmit="return SubmitTest(this);">


function SubmitTest(form){
return (Submit(form) && ValidateForm(form))
}

For it to submit, both Submit and ValidateForm need to evaluate to true.

Abd
10-30-2003, 10:38 AM
Hi liorean,

thanks alot, it work fine.

Abd



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum