This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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

Win a copy of Building Microservices this week in the Design forum!
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:
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: JSF Page validation using Jquery not working
It's not a secret anymore!