如何添加两个“on submit =”值的形式? [英] How to add two "on submit=" values to a form?
本文介绍了如何添加两个“on submit =”值的形式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< form onsubmit =return formCheck(this ); return validate_dropdown();
action =somepage.php
method =post
name =something>
当我在提交值上添加一个时,每个函数都可以单独工作,第一个函数的验证工作,而不是第二个。这里有什么不对?
解决方案
从onsubmit中移除返回并将它们添加到函数中:
onsubmit =return(formCheck(this)&& validate_dropdown())
I am trying to validate my form using two separate JavaScript functions:
<form onsubmit="return formCheck(this); return validate_dropdown();"
action="somepage.php"
method="post"
name="something">
When I add just one on submit value, each function works fine individually, when I add two only the first function's validation works, not the second. What is wrong here?
解决方案
Remove the returns from the onsubmit and add them to the functions:
onsubmit="return (formCheck(this) && validate_dropdown())"
这篇关于如何添加两个“on submit =”值的形式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文