JSF CommandButton onclick不调用Javascript函数 [英] JSF CommandButton onclick does not call Javascript function

查看:488
本文介绍了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;
}


推荐答案


  1. 检查您生成的代码(打开页面 - >查看源代码)

  2. 检查您的javascript控制台(Firefox)是否有错误

  3. 可从正常的< input type =button>

  4. 小写您的按钮类型。

  1. Check your generated code (open the page -> view source)
  2. Check your javascript console (Firefox) for errors
  3. make sure your function is callable from a normal <input type="button">
  4. lowercase your button type.

否则,它应该工作 - 我有完全相同的代码在我当前的代码库工作完美。

Otherwise, it should work - I have exactly the same piece of code in my current codebase that works perfectly.

这篇关于JSF CommandButton onclick不调用Javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆