smansakra
11-30-2008, 05:48 AM
hello....
can anyone here tell me, HOW to make "submit event" on form run after it executes my function?
please see the example below...
<form name="myform" action="login.php" method="post" onsubmit="checking_valid_then_checking_ajax()">
<input type="text" name="u">
<imput type="password" name="p">
<input type="submit" value="submit">
</form>
then the function is below..
function checking_valid_then_checking_ajax(){
if(document.myform.u=="" || document.myform.p==""){
alert('please complete form!');
return false;
}
cheking_ajax();
}
base on the function above, if the user doesnt enter his username and apssword during submitting the form, of course "submiting activity by the form" will be stop.
BUT, if all ok, function will continue to excute "checking_ajax()".
HERE is my problem,
before my code finish its job to execute "checking_ajax()", the "submit event" is still running... so before my checking_ajax() executed, the form has redirected the page to login.php
WHAT i want is, stop "submit event" first, then finish cheking_ajax(), and after "cheking_ajax" return the value "OK", run "submit event" again.
anyone?
can anyone here tell me, HOW to make "submit event" on form run after it executes my function?
please see the example below...
<form name="myform" action="login.php" method="post" onsubmit="checking_valid_then_checking_ajax()">
<input type="text" name="u">
<imput type="password" name="p">
<input type="submit" value="submit">
</form>
then the function is below..
function checking_valid_then_checking_ajax(){
if(document.myform.u=="" || document.myform.p==""){
alert('please complete form!');
return false;
}
cheking_ajax();
}
base on the function above, if the user doesnt enter his username and apssword during submitting the form, of course "submiting activity by the form" will be stop.
BUT, if all ok, function will continue to excute "checking_ajax()".
HERE is my problem,
before my code finish its job to execute "checking_ajax()", the "submit event" is still running... so before my checking_ajax() executed, the form has redirected the page to login.php
WHAT i want is, stop "submit event" first, then finish cheking_ajax(), and after "cheking_ajax" return the value "OK", run "submit event" again.
anyone?