When calling a JavaScript function what does the return value do to an input form field? For example:
<script type="text/javascript">
function foo()
{
return true;
}
</script>
<input type="text" id="txt1" onkeyup="return foo()" />
and variations, IIRC onkeyup="foo(); return false"
I don’t really need a return time, what’s the easiest way to do this?
Right now I’m trying to call multiple functions from one event and not sure what the appropriate way is:
<input type="text" id="txt1" onkeyup="return foo1(); return foo2();" or
<input type="text" id="txt1" onkeyup="return foo1()" onkeyup="return foo2();"
return false;is used to stop the event from having its default effect (in this case, the letter typed from being added).return foo()is used so thatfoocan be the judge of whether toreturn trueorreturn falseand therefore whether or not the default action should happen.If you are just calling a function that won’t affect whether or not the event actually takes place, just use
onkeyup="foo1(); foo2();". If, however, one of them affects the outcome, it should be called last and have areturnbefore it.In general, though, it’s easier to have a single function in there, say
onkeyup="return foo()", and then have