File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes JSF Page validation using Jquery not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF Page validation using Jquery not working" Watch "JSF Page validation using Jquery not working" New topic

JSF Page validation using Jquery not working

Soundarya Sethuraman

Joined: Apr 08, 2014
Posts: 1
I want to validate my JSF page using JQuery. I tried a piece of code. But it did not work. The foll is my code.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns=""
<link rel="stylesheet" href="style.css" />
<!-- Load jQuery and the validate plugin -->
<script src="" type="text/javascript"/>
<script src="" type="text/javascript"/>
<!-- jQuery Form Validation code -->
// When the browser is ready...
// Setup form validation on the #loginform element
var username = $('#userName').val();
var pwd = $('#passwrod').val();
$('#dis').slideDown().html('Please type user name');
return fasle;
$('#dis').slideDown().html('Please type password');
return fasle;
<title>Login Page</title>
<h:form id="loginform">
<h1>Login Page</h1>
<h:message for="userName"/></font>
<h:message for="password"/>
<table border="1" cellpadding="0" cellspacing="0" style="height: 134px">
<td>UserName : </td>
<td><h:inputText id="userName" value="#{loginBean.userName}" /></td>
<td>Password :</td>
<h:inputSecret id="password" value="#{loginBean.password}" />
<h:link value="forgot passwrod" outcome="adduser" /></td>
<td>Role :</td>
<h:selectOneListbox value="#{loginBean.role}" style="height: 31px; width: 66px">
<f:selectItem id="chooserole" itemLabel="choose role"/>
<f:selectItem id="admin" itemLabel="admin" itemValue="admin" />
<f:selectItem id="user" itemLabel="user" itemValue="user" />
<h:commandButton value="Clear" type="reset" actionListener="#{loginBean.clear}" immediate="true"/>
<h:commandButton value="Login" action="#{loginBean.findUser}" />

I have added the following dependency in my Pom:



Please help me find out what the prob is.
Seven SpecialGems

Joined: Apr 08, 2014
Posts: 3
Have you considered using Primefaces? Primefaces brings jQuery to JSF's components:

jQuery in Action, 2nd edition
subject: JSF Page validation using Jquery not working
Similar Threads
Spring MVC - Question
JSF - Missing source code using templating and composition
unable to load faces-config.xml
binding xhtml and bean not working and the problem is : javax.el.PropertyNotFoundException