admin管理员组文章数量:1415095
I have a form through which i am finding distance between two locations. right now my form works fine.i have used.
<form method="get" name="f1" id="f1" class="formular" action="findcars.php" onsubmit="showLocation(); return false;">
Now i want to validate all form inputs.. so i have added the function validate(); like this
<form method="get" name="f1" id="f1" class="formular" action="findcars.php" onsubmit="validate(); showLocation(); return false;">
But this is not working..pls..help, how should i call this validate() function.
Thanks.
I have a form through which i am finding distance between two locations. right now my form works fine.i have used.
<form method="get" name="f1" id="f1" class="formular" action="findcars.php" onsubmit="showLocation(); return false;">
Now i want to validate all form inputs.. so i have added the function validate(); like this
<form method="get" name="f1" id="f1" class="formular" action="findcars.php" onsubmit="validate(); showLocation(); return false;">
But this is not working..pls..help, how should i call this validate() function.
Thanks.
Share Improve this question asked Mar 13, 2013 at 11:28 DevDev 4796 silver badges15 bronze badges 4-
try this
javascript:validate();
– Sumit Bijvani Commented Mar 13, 2013 at 11:30 - @Sumit yes,i have made validate(); , but the problem is that script doesn't call that function – Dev Commented Mar 13, 2013 at 11:32
-
@SumitBijvani the prefix
javascript:
inon…
attributes is a mistake. It's never needed, it doesn't do anything (it doesn't cause syntax error only because it happens to match break/continue labels syntax) – Kornel Commented Mar 13, 2013 at 11:35 - can you please write the code here for function validate() – Praveen kalal Commented Mar 13, 2013 at 11:45
6 Answers
Reset to default 1Maybe you could try this
<form method="get" name="f1" id="f1" class="formular" action="findcars.php" onsubmit="myFunction(); return false;">
<script>
myFunction function () {
validate();
showLocation();
}
</script>
try doing
validate() && showLocation();
or, calling one master function which then runs a chain:
masterFunction();
function masterFunction() {
validate();
showLocation();
}
Try this
<form method="get" name="f1" id="f1" class="formular" action="findcars.php" onsubmit="validate(); showLocation(); return false;">
<button id="search-submit" type="submit">Search</button>
</form>
Javascript
function validate(){
alert('validate');
}
function showLocation(){
alert('Location');
}
do in this way..
<form method="get" name="f1" id="f1" class="formular" action="findcars.php" onsubmit="return myvalidations();">
function myvalidations() {
validate();
showLocation();
}
Arrange functions like this:
<input type="button" onclick="function1();function2();" value="Call2Functions" />
function func1(){
//--- some logic
func2();
}
function func2(){
//--- some logic
}
First call only validate() method if return true then call second method inside it. like below
function validate(){
// ok is output of your validate method whether true or false
if(ok){
showLocation();
}
else{
return false;
}
}
本文标签: phpCalling multiple functions on quotOnsubmitquotStack Overflow
版权声明:本文标题:php - Calling multiple functions on "Onsubmit" - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745153166a2645010.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论