JSF CommandButton onclick 不调用 Javascript 函数 [英] JSF CommandButton onclick does not call Javascript function
本文介绍了JSF CommandButton onclick 不调用 Javascript 函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用来自 JSF 的命令按钮.我不知道为什么我不能调用我的 javascript 函数.单击按钮时不会显示任何警报.
I am using a command button from JSF. I don't know why I can't call my javascript function. NO alert will show when I click the button.
<h:commandButton id="login" value="Login" action="login"
onclick="return checkPasswords();" type="Submit" />
我的 Javascript 函数:
My Javascript function:
function checkPasswords() {
alert("test");
return false;
}
推荐答案
- 检查您生成的代码(打开页面 -> 查看源代码)
- 检查您的 javascript 控制台 (Firefox) 是否有错误
- 确保您的函数可以从普通
<input type="button">
调用 - 小写您的按钮类型.
否则,它应该可以工作 - 我当前的代码库中有完全相同的代码,可以完美运行.
Otherwise, it should work - I have exactly the same piece of code in my current codebase that works perfectly.
这篇关于JSF CommandButton onclick 不调用 Javascript 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文