Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript return false - from function

Is there any way to do the following:

validateLogin();
return false;

But actually like this..

validateLogin();

And here is the function:

function validateLogin(){
if(hi=true){
return true;
}
else{
return false
}

I want to attach this function for the event of a form being submitted, so if HI is false - i want to return false; meaning it will stop for form from submitting.. i know return false; will do so i just need to know how i can get this return back to the parent function?

Thanks in advance!

like image 472
tarnfeld Avatar asked Aug 28 '26 02:08

tarnfeld


1 Answers

You can use it as follow:

return validateLogin();

however, as mmayo pointed out, don't forget about the return value:

event.returnValue = false;
like image 100
mbillard Avatar answered Aug 30 '26 16:08

mbillard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!