JSF CommandButton onclick не вызывает функцию JavaScript

Я использую кнопку от JSF. Я не знаю, почему я не могу вызвать свою функцию JavaScript. НИКАКОЕ предупреждение не покажет, когда я нажму кнопку.

<h:commandButton id="login" value="Login" action="login"
   onclick="return checkPasswords();" type="Submit" /> 

Моя функция JavaScript:

function checkPasswords() {
    alert("test");
    return false;
}
5
задан BalusC 17 December 2009 в 11:58
поделиться

3 ответа

  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
  4. lowercase your button type.

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

5
ответ дан 13 December 2019 в 22:09
поделиться

This is working

<script type="text/javascript">
function checkPasswords() {
   alert("test");
   return false;
}

<h:commandButton  id="login" value="Login" action="login"
             onclick="checkPasswords();" type="submit"/>
3
ответ дан 13 December 2019 в 22:09
поделиться

Give s in lowercase in type="submit", The type attribute sets the type of button to create for this component. The valid values for this attribute are "submit" and "reset". The default value for this attribute is "submit".

2
ответ дан 13 December 2019 в 22:09
поделиться
Другие вопросы по тегам:

Похожие вопросы: