jQuery in Action, 3rd edition
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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 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="http://www.w3.org/1999/xhtml"
<link rel="stylesheet" href="style.css" />
<!-- Load jQuery and the validate plugin -->
<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"/>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js" 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 agree. Here's the link: http://aspose.com/file-tools
subject: JSF Page validation using Jquery not working
It's not a secret anymore!